結果

問題 No.486 3 Straight Win(3連勝)
ユーザー samplelpmas
提出日時 2017-04-07 21:30:03
言語 Java
(openjdk 23)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 960 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 74,188 KB
実行使用メモリ 41,652 KB
最終ジャッジ日時 2024-06-26 04:25:19
合計ジャッジ時間 6,154 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        char[] winLossRecord = sc.next().toCharArray();

        char previous = ' ';
        int winCount = 0;

        for (int i = 0; i < winLossRecord.length; i++) {

            char current = winLossRecord[i];

            if (previous == current) {

                winCount++;

                if (3 <= winCount) {

                    switch (current) {

                        case 'O' :
                            System.out.println("East");
                            return;
                        case 'X' :
                            System.out.println("West");
                            return;

                    }

                }

            } else {

                previous = current;
                winCount = 1;

            }

        }

        System.out.println("NA");

    }

}
0