結果

問題 No.1016 三目並べ
ユーザー ks2mks2m
提出日時 2020-04-03 21:50:13
言語 Java19
(openjdk 21)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 1,058 bytes
コンパイル時間 2,524 ms
コンパイル使用メモリ 73,568 KB
実行使用メモリ 52,620 KB
最終ジャッジ日時 2023-09-16 01:04:01
合計ジャッジ時間 3,872 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,364 KB
testcase_01 AC 46 ms
49,568 KB
testcase_02 AC 44 ms
49,428 KB
testcase_03 AC 47 ms
49,436 KB
testcase_04 AC 48 ms
49,376 KB
testcase_05 AC 49 ms
49,472 KB
testcase_06 AC 47 ms
49,596 KB
testcase_07 AC 90 ms
52,060 KB
testcase_08 AC 82 ms
50,548 KB
testcase_09 AC 99 ms
52,620 KB
testcase_10 AC 106 ms
52,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		PrintWriter pw = new PrintWriter(System.out);
		label:
		for (int i = 0; i < t; i++) {
			String[] sa = br.readLine().split(" ");
			String s = sa[1];
			if (s.indexOf("ooo") != -1
					|| s.indexOf("oo-") != -1
					|| s.indexOf("-oo") != -1
					|| s.indexOf("--o-") != -1
					|| s.indexOf("-o--") != -1
					|| s.indexOf("o-o") != -1
					) {
				pw.println("O");
			} else {
				int cnt = 0;
				for (int j = 0; j < s.length(); j++) {
					if (s.charAt(j) == 'o') {
						if (cnt > 0 && cnt % 2 == 0) {
							pw.println("O");
							continue label;
						}
						cnt = 1;
					} else if (s.charAt(j) == 'x') {
						cnt = 0;
					} else {
						if (cnt > 0) {
							cnt++;
						}
					}
				}
				pw.println("X");
			}
		}
		br.close();
		pw.flush();
	}
}
0