結果

問題 No.74 貯金箱の退屈
ユーザー nebukuro09nebukuro09
提出日時 2017-06-15 11:03:35
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,395 bytes
コンパイル時間 652 ms
コンパイル使用メモリ 105,216 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 14:21:52
合計ジャッジ時間 2,034 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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");
}


0