結果
| 問題 |
No.74 貯金箱の退屈
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-15 11:03:35 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,395 bytes |
| コンパイル時間 | 591 ms |
| コンパイル使用メモリ | 118,740 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 20:03:45 |
| 合計ジャッジ時間 | 1,459 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 11 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;
bool gaussianElimination(ref int[][] org_mat) {
int N = org_mat.length.to!int;
auto mat = new int[][](N, N+1);
foreach (i; 0..N)
foreach (j; 0..N+1)
mat[i][j] = org_mat[i][j];
foreach (i; 0..N) {
int maxval = 0;
int maxrow = -1;
foreach (j; i..N)
if (abs(mat[j][i]) > maxval)
maxval = abs(mat[j][i]), maxrow = j;
if (maxval == 0)
continue;
swap(mat[i], mat[maxrow]);
foreach (j; 0..N) {
if (j == i) continue;
int mul = mat[j][i];
foreach (k; i..N+1)
mat[j][k] ^= mul*mat[i][k];
}
}
bool ok = true;
foreach (i; 0..N) if (mat[i][0..N].map!(m => m == 0).all && mat[i][N] != 0) ok = false;
return ok;
}
void main() {
auto N = readln.chomp.to!int;
auto D = readln.split.map!(to!int).array;
auto W = readln.split.map!(to!int).array;
auto mat = new int[][](N, N+1);
foreach (i; 0..N) {
mat[i][(i+D[i])%N] = 1;
mat[i][((i-D[i])%N+N)%N] = 1;
mat[i][N] = 1;
}
//mat.writeln;
writeln( gaussianElimination(mat) ? "Yes" : "No");
}