結果

問題 No.387 ハンコ
ユーザー nebukuro09nebukuro09
提出日時 2017-11-10 12:17:02
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 3,896 ms / 5,000 ms
コード長 881 bytes
コンパイル時間 4,368 ms
コンパイル使用メモリ 109,140 KB
実行使用メモリ 32,692 KB
最終ジャッジ日時 2023-09-03 16:45:04
合計ジャッジ時間 28,661 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,895 ms
31,260 KB
testcase_01 AC 3,896 ms
32,692 KB
testcase_02 AC 1,690 ms
14,552 KB
testcase_03 AC 1,692 ms
14,476 KB
testcase_04 AC 533 ms
8,716 KB
testcase_05 AC 1,475 ms
21,316 KB
testcase_06 AC 2,391 ms
31,152 KB
testcase_07 AC 1,780 ms
15,544 KB
testcase_08 AC 1,725 ms
14,684 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, std.bitmanip;


void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    auto B = readln.split.map!(c => c == "1").array;

    int[][int] rev;
    foreach (i, a; A.enumerate) 
        rev[a] ~= i.to!int;
    
    BitArray bs;
    bs.length = N * 2 - 1;
    foreach (i; 0..N)
        bs[i] = B[i];
    
    BitArray ans;
    ans.length = N * 2 - 1;

    foreach (c; rev.keys) {
        BitArray tmp;
        tmp.length = N * 2 - 1;
        
        foreach (i; rev[c]) {
            BitArray bsbs = bs.dup;
            bsbs <<= i;
            tmp |= bsbs;
        }

        ans ^= tmp;
    }

    (2*N-1).iota.map!(i => ans[i] ? "ODD" : "EVEN").each!writeln;
}
0