結果

問題 No.387 ハンコ
コンテスト
ユーザー nebukuro09
提出日時 2017-11-10 12:17:02
言語 D
(dmd 2.111.0)
結果
AC  
実行時間 3,951 ms / 5,000 ms
コード長 881 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 894 ms
コンパイル使用メモリ 113,628 KB
実行使用メモリ 30,292 KB
最終ジャッジ日時 2025-12-26 10:26:15
合計ジャッジ時間 25,601 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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