結果

問題 No.870 無敵囲い
ユーザー ks2mks2m
提出日時 2019-08-30 21:35:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 45 ms / 300 ms
コード長 1,462 bytes
コンパイル時間 2,133 ms
コンパイル使用メモリ 73,956 KB
実行使用メモリ 49,776 KB
最終ジャッジ日時 2023-09-11 16:09:55
合計ジャッジ時間 3,994 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,256 KB
testcase_01 AC 42 ms
49,280 KB
testcase_02 AC 41 ms
49,336 KB
testcase_03 AC 41 ms
49,776 KB
testcase_04 AC 42 ms
49,400 KB
testcase_05 AC 42 ms
49,488 KB
testcase_06 AC 43 ms
49,400 KB
testcase_07 AC 45 ms
49,696 KB
testcase_08 AC 43 ms
49,260 KB
testcase_09 AC 42 ms
49,296 KB
testcase_10 AC 43 ms
49,476 KB
testcase_11 AC 43 ms
49,232 KB
testcase_12 AC 43 ms
49,412 KB
testcase_13 AC 42 ms
49,252 KB
testcase_14 AC 42 ms
49,284 KB
testcase_15 AC 43 ms
49,516 KB
testcase_16 AC 42 ms
49,412 KB
testcase_17 AC 42 ms
49,512 KB
testcase_18 AC 42 ms
49,428 KB
testcase_19 AC 43 ms
49,356 KB
testcase_20 AC 43 ms
47,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[][] x = new int[n][4];
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			for (int j = 0; j < 4; j++) {
				x[i][j] = Integer.parseInt(sa[j]);
			}
		}
		br.close();

		boolean[] flg = new boolean[3];
		int[][] a = new int[3][];
		a[0] = new int[]{2, 8};
		a[1] = new int[]{3, 9};
		a[2] = new int[]{7, 9};
		for (int i = 0; i < n; i++) {
			if (!flg[0] && x[i][2] == 2 && x[i][3] == 8) {
				System.out.println("NO");
				return;
			}
			if (!flg[1] && x[i][2] == 3 && x[i][3] == 9) {
				System.out.println("NO");
				return;
			}
			if (!flg[2] && x[i][2] == 7 && x[i][3] == 9) {
				System.out.println("NO");
				return;
			}

			if (x[i][0] == 2 && x[i][1] == 8) {
				flg[0] = true;
			}
			if (x[i][0] == 3 && x[i][1] == 9) {
				flg[1] = true;
			}
			if (x[i][0] == 7 && x[i][1] == 9) {
				flg[2] = true;
			}

			for (int j = 0; j < a.length; j++) {
				if (x[i][0] == a[j][0] && x[i][1] == a[j][1]) {
					a[j][0] = x[i][2];
					a[j][1] = x[i][3];
				}
			}
		}
		if (a[0][0] == 5 && a[0][1] == 8
				&& a[1][0] == 4 && a[1][1] == 8
				&& a[2][0] == 6 && a[2][1] == 8) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}
0