結果

問題 No.74 貯金箱の退屈
ユーザー ぴろずぴろず
提出日時 2015-04-19 12:59:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 973 bytes
コンパイル時間 2,049 ms
コンパイル使用メモリ 74,360 KB
実行使用メモリ 56,184 KB
最終ジャッジ日時 2023-09-18 00:47:30
合計ジャッジ時間 8,309 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,496 KB
testcase_01 AC 126 ms
55,760 KB
testcase_02 AC 126 ms
55,932 KB
testcase_03 AC 134 ms
55,544 KB
testcase_04 AC 134 ms
55,652 KB
testcase_05 AC 134 ms
55,764 KB
testcase_06 AC 133 ms
55,732 KB
testcase_07 AC 134 ms
55,620 KB
testcase_08 AC 140 ms
55,524 KB
testcase_09 AC 133 ms
53,636 KB
testcase_10 AC 134 ms
55,564 KB
testcase_11 AC 136 ms
55,992 KB
testcase_12 AC 133 ms
55,564 KB
testcase_13 AC 141 ms
56,184 KB
testcase_14 AC 146 ms
55,324 KB
testcase_15 AC 141 ms
55,816 KB
testcase_16 AC 141 ms
55,792 KB
testcase_17 AC 133 ms
55,648 KB
testcase_18 AC 125 ms
56,044 KB
testcase_19 AC 132 ms
55,720 KB
testcase_20 AC 140 ms
55,716 KB
testcase_21 AC 142 ms
55,788 KB
testcase_22 AC 132 ms
55,480 KB
testcase_23 AC 132 ms
55,696 KB
testcase_24 AC 141 ms
55,496 KB
testcase_25 AC 142 ms
55,744 KB
testcase_26 AC 141 ms
55,604 KB
testcase_27 AC 143 ms
55,724 KB
testcase_28 AC 140 ms
55,576 KB
testcase_29 AC 141 ms
55,780 KB
testcase_30 AC 140 ms
55,700 KB
testcase_31 AC 141 ms
55,400 KB
testcase_32 AC 135 ms
55,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no074;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[n+1][n];
		int[] d = new int[n];
		int[] w = new int[n];
		for(int i=0;i<n;i++) {
			d[i] = sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			w[i] = sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			int f1 = (i+d[i])%n;
			int f2 = ((i-d[i])%n+n)%n;
			a[i][f1] = a[i][f2] = 1;
			a[n][i] = 1 - w[i];
		}
		int rank = 0;
		for(int j=0;j<n;j++) {
			for(int i=rank;i<n;i++) {
				if (a[i][j] == 0) {
					continue;
				}
				int[] temp = a[rank];
				a[rank] = a[i];
				a[i] = temp;
				for(int k=rank+1;k<=n;k++) {
					if (a[k][j] == 1) {
						for(int l=0;l<n;l++) {
							a[k][l] ^= a[rank][l];
						}
					}
				}
				rank++;
			}
		}
		boolean flag = true;
		for(int i=0;i<n;i++) {
			if (a[n][i] == 1) {
				flag = false;
			}
 		}
		System.out.println(flag ? "Yes" : "No");
	}

}
0