結果

問題 No.486 3 Straight Win(3連勝)
ユーザー AoiroFukurouAoiroFukurou
提出日時 2017-02-26 13:49:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 3,222 ms
コンパイル使用メモリ 72,136 KB
実行使用メモリ 56,248 KB
最終ジャッジ日時 2023-09-08 10:50:08
合計ジャッジ時間 8,004 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,744 KB
testcase_01 AC 121 ms
55,536 KB
testcase_02 AC 119 ms
55,744 KB
testcase_03 AC 124 ms
55,936 KB
testcase_04 AC 125 ms
55,888 KB
testcase_05 AC 123 ms
56,048 KB
testcase_06 AC 123 ms
55,788 KB
testcase_07 AC 122 ms
55,668 KB
testcase_08 AC 122 ms
55,916 KB
testcase_09 AC 125 ms
55,644 KB
testcase_10 AC 123 ms
53,404 KB
testcase_11 AC 122 ms
55,756 KB
testcase_12 AC 124 ms
55,508 KB
testcase_13 AC 122 ms
55,928 KB
testcase_14 AC 124 ms
55,972 KB
testcase_15 AC 122 ms
55,672 KB
testcase_16 AC 125 ms
55,916 KB
testcase_17 AC 123 ms
55,916 KB
testcase_18 AC 123 ms
55,732 KB
testcase_19 AC 124 ms
56,248 KB
testcase_20 AC 125 ms
56,116 KB
testcase_21 AC 124 ms
55,704 KB
testcase_22 AC 124 ms
55,892 KB
testcase_23 AC 124 ms
55,884 KB
testcase_24 AC 127 ms
55,664 KB
testcase_25 AC 122 ms
53,764 KB
testcase_26 AC 123 ms
55,700 KB
testcase_27 AC 124 ms
56,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No_486 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int O = 0;
		int X = 0;
		for (int i = 1; i <= s.length(); i++) {
			String s2 = s.substring(i - 1, i);
			if (s2.equals("O")) {
				O++;
				X = 0;
			} else if (s2.equals("X")) {
				X++;
				O = 0;
			}
			if(O >= 3 || X >= 3){
				break;
			}
		}
		if (O == 3) {
			System.out.println("East");
		} else if (X == 3) {
			System.out.println("West");
		} else {
			System.out.println("NA");
		}
	}
}
0