結果
問題 | No.387 ハンコ |
ユーザー |
|
提出日時 | 2017-07-25 17:18:48 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 4,514 ms / 5,000 ms |
コード長 | 983 bytes |
コンパイル時間 | 3,908 ms |
コンパイル使用メモリ | 101,292 KB |
実行使用メモリ | 22,464 KB |
最終ジャッジ日時 | 2024-12-13 08:05:27 |
合計ジャッジ時間 | 29,065 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;import std.bitmanip; // BitArrayvoid main(){auto n = readln.chomp.to!size_t;auto newBitArray() {auto r = BitArray();r.length = 2*n-1;return r;}auto a = new int[](n), rda = readln.chomp.splitter;foreach (i; 0..n) {a[i] = rda.front.to!int;rda.popFront();}auto b = newBitArray(), rdb = readln.chomp.splitter;foreach (i; 0..n) {b[i] = rdb.front.to!int.to!bool;rdb.popFront();}auto shift(ref BitArray ba, size_t n){if (n > 0 && n % 64 == 0) {ba <<= 1;ba <<= n-1;} else {ba <<= n;}}size_t[][int] c;foreach (i, ai; a) c[ai] ~= i;auto r = newBitArray();foreach (ci; c.byValue) {auto d = newBitArray(), e = b.dup, p = size_t(0);foreach (cii; ci) {shift(e, cii - p);d |= e;p = cii;}r ^= d;}foreach (i; 0..2*n-1)writeln(r[i] ? "ODD" : "EVEN");}