結果

問題 No.486 3 Straight Win(3連勝)
ユーザー tenten
提出日時 2020-11-12 08:15:32
言語 Java
(openjdk 23)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 2,130 ms
コンパイル使用メモリ 77,916 KB
実行使用メモリ 41,608 KB
最終ジャッジ日時 2024-07-22 19:00:01
合計ジャッジ時間 6,922 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

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