結果
| 問題 |
No.74 貯金箱の退屈
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-02 11:23:57 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,281 bytes |
| コンパイル時間 | 866 ms |
| コンパイル使用メモリ | 116,116 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-12 19:37:31 |
| 合計ジャッジ時間 | 1,726 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 12 |
ソースコード
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;
int 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)
return 0;
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];
}
}
return 1;
}
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");
}