結果

問題 No.486 3 Straight Win(3連勝)
ユーザー tentententen
提出日時 2020-11-12 08:15:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 72,208 KB
実行使用メモリ 56,076 KB
最終ジャッジ日時 2023-09-30 01:04:11
合計ジャッジ時間 7,378 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
56,052 KB
testcase_01 AC 119 ms
55,944 KB
testcase_02 AC 124 ms
55,796 KB
testcase_03 AC 115 ms
55,532 KB
testcase_04 AC 117 ms
55,792 KB
testcase_05 AC 114 ms
55,704 KB
testcase_06 AC 118 ms
55,728 KB
testcase_07 AC 121 ms
55,392 KB
testcase_08 AC 120 ms
53,568 KB
testcase_09 AC 117 ms
55,644 KB
testcase_10 AC 118 ms
55,632 KB
testcase_11 AC 118 ms
56,076 KB
testcase_12 AC 118 ms
55,608 KB
testcase_13 AC 117 ms
55,932 KB
testcase_14 AC 115 ms
55,856 KB
testcase_15 AC 129 ms
55,736 KB
testcase_16 AC 130 ms
55,404 KB
testcase_17 AC 124 ms
55,556 KB
testcase_18 AC 123 ms
56,000 KB
testcase_19 AC 124 ms
39,156 KB
testcase_20 AC 121 ms
39,384 KB
testcase_21 AC 128 ms
39,124 KB
testcase_22 AC 126 ms
51,840 KB
testcase_23 AC 121 ms
55,600 KB
testcase_24 AC 121 ms
55,708 KB
testcase_25 AC 122 ms
55,320 KB
testcase_26 AC 125 ms
55,668 KB
testcase_27 AC 122 ms
55,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        for (char c : sc.next().toCharArray()) {
            if (c == 'O') {
                if (count < 0) {
                    count = 0;
                }
                count++;
            } else {
                if (count > 0) {
                    count = 0;
                }
                
                count--;
            }
            if (count >= 3) {
                System.out.println("East");
                return;
            } else if (count <= - 3) {
                System.out.println("West");
                return;
            }
        }
        System.out.println("NA");
    }
}
0