結果

問題 No.74 貯金箱の退屈
ユーザー pekempeypekempey
提出日時 2016-12-22 22:28:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 755 bytes
コンパイル時間 1,542 ms
コンパイル使用メモリ 166,464 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-21 05:46:56
合計ジャッジ時間 2,751 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	static bitset<123> a[100];
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		int x = (i + d) % n;
		int y = (i - d) % n;
		if (y < 0) y += n;
		a[x][i] = true;
		a[y][i] = true;
	}
	for (int i = 0; i < n; i++) {
		int w;
		cin >> w;
		a[i][n] = !w;
	}

	int r = 0;
	for (int k = 0; k < n; k++) {
		int p = -1;
		for (int i = r; i < n; i++) {
			if (a[i][k]) {
				p = i;
				break;
			}
		}
		if (p == -1) {
			continue;
		}
		swap(a[r], a[p]);
		for (int i = 0; i < n; i++) {
			if (i == r) {
				continue;
			}
			if (a[i][k]) {
				a[i] ^= a[r];
			}
		}
		r++;
	}
	for (int i = r; i < n; i++) {
		if (a[i][n] != 0) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}
0