結果

問題 No.486 3 Straight Win(3連勝)
ユーザー shinwisteriashinwisteria
提出日時 2017-03-18 16:10:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 3,896 ms
コンパイル使用メモリ 72,436 KB
実行使用メモリ 56,240 KB
最終ジャッジ日時 2023-09-08 11:03:53
合計ジャッジ時間 8,171 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,712 KB
testcase_01 AC 120 ms
55,800 KB
testcase_02 AC 120 ms
55,728 KB
testcase_03 AC 121 ms
55,648 KB
testcase_04 AC 117 ms
55,704 KB
testcase_05 AC 119 ms
55,720 KB
testcase_06 AC 122 ms
55,476 KB
testcase_07 AC 121 ms
55,824 KB
testcase_08 AC 124 ms
55,616 KB
testcase_09 AC 119 ms
55,696 KB
testcase_10 AC 118 ms
55,628 KB
testcase_11 AC 120 ms
55,784 KB
testcase_12 AC 119 ms
55,836 KB
testcase_13 AC 117 ms
55,608 KB
testcase_14 AC 119 ms
55,592 KB
testcase_15 AC 117 ms
56,240 KB
testcase_16 AC 120 ms
55,564 KB
testcase_17 AC 119 ms
56,012 KB
testcase_18 AC 120 ms
56,016 KB
testcase_19 AC 121 ms
55,412 KB
testcase_20 AC 118 ms
55,352 KB
testcase_21 AC 122 ms
55,900 KB
testcase_22 AC 119 ms
55,848 KB
testcase_23 AC 118 ms
55,732 KB
testcase_24 AC 122 ms
55,768 KB
testcase_25 AC 118 ms
55,804 KB
testcase_26 AC 120 ms
55,716 KB
testcase_27 AC 118 ms
55,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class EWgame {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] c = new char[str.length()];
		for(int i = 0;i<str.length();i++){
			c[i] = str.charAt(i);
		}
		
		int east = 0,west = 0;
		for(int i = 0;i < str.length();i++){
			if(c[i] == 'O'){
				east++;
				west = 0;
				if(east >= 3){
					System.out.println("East");
					break;
				}
			}else if(c[i] == 'X'){
				east = 0;
				west++;
				if(west >= 3){
					System.out.println("West");
					break;
				}
			}
		}
		if(east<3 && west < 3){
			System.out.println("NA");
		}

	}

}
0