Submission #33652


Source Code Expand

Copy
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main{
    public static void main(String[] args) throws Exception{
        new Main().run();
    }

    int w, h;
    char[][] a;

    boolean ok(int start){
        int x = start;
        int y = 0;
        while(y < h){
            if(x > 0 && a[y][x-1] == '-')x -= 2;
            else if(x < a[y].length-1 && a[y][x+1] == '-') x += 2;
            y++;
        }
        return a[y][x] == 'o';
    }

    void run() throws Exception{
        //Scanner sc = new Scanner(System.in);
        BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
        // only sc.readLine() is available
        String[] wh = sc.readLine().split(" ");
        w = Integer.parseInt(wh[0]);
        h = Integer.parseInt(wh[1]);
        a = new char[h+1][];
        for(int i = 0; i <= h; i++)
            a[i] = sc.readLine().toCharArray();
        int ans = 0;
        for(int i = 0; i < w; i++)
            if(ok(i*2))
                ans = i;
        System.out.println(ans+1);
    }
}

Submission Info

Submission Time
Task B - あみだくじ
User chronotable
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 1115 Byte
Status AC
Exec Time 423 ms
Memory 19060 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 34
Set Name Test Cases
All 00_min.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_maxrnd_00.txt, 02_maxrnd_01.txt, 02_maxrnd_02.txt, 02_maxrnd_03.txt, 02_maxrnd_04.txt, 03_empty_00.txt, 03_empty_01.txt, 03_empty_02.txt
Case Name Status Exec Time Memory
00_min.txt AC 400 ms 19048 KB
00_sample_01.txt AC 423 ms 18908 KB
00_sample_02.txt AC 419 ms 18916 KB
00_sample_03.txt AC 411 ms 18984 KB
00_sample_04.txt AC 402 ms 18924 KB
00_sample_05.txt AC 401 ms 18876 KB
01_rnd_00.txt AC 407 ms 18936 KB
01_rnd_01.txt AC 403 ms 18976 KB
01_rnd_02.txt AC 399 ms 18980 KB
01_rnd_03.txt AC 417 ms 19036 KB
01_rnd_04.txt AC 406 ms 19020 KB
01_rnd_05.txt AC 396 ms 18988 KB
01_rnd_06.txt AC 407 ms 18988 KB
01_rnd_07.txt AC 400 ms 18928 KB
01_rnd_08.txt AC 404 ms 18932 KB
01_rnd_09.txt AC 400 ms 19044 KB
01_rnd_10.txt AC 399 ms 18928 KB
01_rnd_11.txt AC 394 ms 18936 KB
01_rnd_12.txt AC 423 ms 18988 KB
01_rnd_13.txt AC 398 ms 18928 KB
01_rnd_14.txt AC 416 ms 18916 KB
01_rnd_15.txt AC 415 ms 19056 KB
01_rnd_16.txt AC 398 ms 18996 KB
01_rnd_17.txt AC 399 ms 18996 KB
01_rnd_18.txt AC 401 ms 18916 KB
01_rnd_19.txt AC 420 ms 18992 KB
02_maxrnd_00.txt AC 401 ms 18920 KB
02_maxrnd_01.txt AC 391 ms 19040 KB
02_maxrnd_02.txt AC 396 ms 19044 KB
02_maxrnd_03.txt AC 404 ms 18928 KB
02_maxrnd_04.txt AC 402 ms 18936 KB
03_empty_00.txt AC 399 ms 19036 KB
03_empty_01.txt AC 393 ms 19060 KB
03_empty_02.txt AC 386 ms 18916 KB