結果

問題 No.1941 CHECKER×CHECKER(1)
ユーザー eagleeagle
提出日時 2022-05-28 13:23:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 1,375 bytes
コンパイル時間 2,982 ms
コンパイル使用メモリ 77,716 KB
実行使用メモリ 57,720 KB
最終ジャッジ日時 2023-10-20 23:03:18
合計ジャッジ時間 6,468 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
57,180 KB
testcase_01 AC 131 ms
57,516 KB
testcase_02 AC 133 ms
57,392 KB
testcase_03 AC 129 ms
57,428 KB
testcase_04 AC 128 ms
57,444 KB
testcase_05 AC 131 ms
57,436 KB
testcase_06 AC 133 ms
57,504 KB
testcase_07 AC 132 ms
57,132 KB
testcase_08 AC 126 ms
57,432 KB
testcase_09 AC 133 ms
57,448 KB
testcase_10 AC 135 ms
57,404 KB
testcase_11 AC 130 ms
57,436 KB
testcase_12 AC 131 ms
57,720 KB
testcase_13 AC 128 ms
57,464 KB
testcase_14 AC 133 ms
57,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		char[][] S = new char[3][3];
		for(int i = 0; i < 3; i++) {
			String str = sc.next();
			for(int j = 0; j < 3; j++) {
				S[i][j] = str.charAt(j);
			}
		}
		//横一列が条件を満たすか確認する
		boolean flg = true;
		String ans;
		for(int i = 0; i < 3; i++) {
			//左端の文字を取り出す
			char moji = S[i][0];
			for(int j = 1; j < 3; j++) {
				//隣と同じ文字の場合ループを終了する
				if(moji == S[i][j]) {
					flg = false;
					break;
				}
				moji = S[i][j];
			}
			//隣で同じ文字が見つかった場合ループを終了する
			if(!flg) {
				break;
			}
		}
		if(flg) {
			//縦一列が条件を満たすか確認する
			for(int j = 0; j < 3; j++) {
				//上端の文字を取り出す
				char moji = S[0][j];
				for(int i = 1; i < 3; i++) {
					//隣と同じ文字の場合ループを終了する
					if(moji == S[i][j]) {
						flg = false;
						break;
					}
					moji = S[i][j];
				}
				//隣で同じ文字が見つかった場合ループを終了する
				if(!flg) {
					break;
				}
			}
			if(flg) {
				ans = "Yes";
			} else {
				ans = "No";
			}
		} else {
			ans = "No";
		}
		System.out.println(ans);
	}
}
0