結果

問題 No.486 3 Straight Win(3連勝)
ユーザー samplelpmassamplelpmas
提出日時 2017-04-07 21:30:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 960 bytes
コンパイル時間 2,721 ms
コンパイル使用メモリ 71,852 KB
実行使用メモリ 56,300 KB
最終ジャッジ日時 2023-09-08 11:06:18
合計ジャッジ時間 7,030 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,488 KB
testcase_01 AC 127 ms
55,936 KB
testcase_02 AC 122 ms
55,600 KB
testcase_03 AC 125 ms
55,460 KB
testcase_04 AC 120 ms
55,644 KB
testcase_05 AC 125 ms
55,656 KB
testcase_06 AC 122 ms
55,600 KB
testcase_07 AC 122 ms
55,996 KB
testcase_08 AC 123 ms
56,112 KB
testcase_09 AC 119 ms
55,472 KB
testcase_10 AC 129 ms
55,420 KB
testcase_11 AC 127 ms
55,812 KB
testcase_12 AC 124 ms
56,060 KB
testcase_13 AC 118 ms
55,552 KB
testcase_14 AC 118 ms
55,992 KB
testcase_15 AC 131 ms
55,748 KB
testcase_16 AC 131 ms
55,680 KB
testcase_17 AC 124 ms
55,588 KB
testcase_18 AC 128 ms
55,704 KB
testcase_19 AC 121 ms
55,580 KB
testcase_20 AC 120 ms
56,300 KB
testcase_21 AC 119 ms
55,820 KB
testcase_22 AC 123 ms
55,664 KB
testcase_23 AC 120 ms
55,500 KB
testcase_24 AC 122 ms
55,660 KB
testcase_25 AC 119 ms
55,724 KB
testcase_26 AC 121 ms
55,736 KB
testcase_27 AC 120 ms
55,704 KB
権限があれば一括ダウンロードができます

ソースコード

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