結果
問題 |
No.184 たのしい排他的論理和(HARD)
|
ユーザー |
|
提出日時 | 2016-09-13 13:35:16 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 96 ms / 5,000 ms |
コード長 | 1,085 bytes |
コンパイル時間 | 709 ms |
コンパイル使用メモリ | 120,472 KB |
実行使用メモリ | 7,240 KB |
最終ジャッジ日時 | 2024-06-12 04:19:51 |
合計ジャッジ時間 | 3,574 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.regex, std.conv, std.stdio, std.typecons; template BitOp(T) { bool bitTest(T n, size_t i) { return (n & (1.to!T << i)) != 0; } T bitSet(T n, size_t i) { return n | (1.to!T << i); } T bitReset(T n, size_t i) { return n & ~(1.to!T << i); } T bitComp(T n, size_t i) { return n ^ (1.to!T << i); } int bsf(T n) { return core.bitop.bsf(n.to!ulong); } int bsr(T n) { return core.bitop.bsr(n.to!ulong); } int popcnt(T n) { return core.bitop.popcnt(n.to!ulong); } } mixin BitOp!ulong; void main() { auto n = readln.chomp.to!size_t; auto ai = readln.split.map!(to!ulong).array; size_t i = 0; foreach (j; 0..61) { if (i >= n) break; auto k = ai[i..$].countUntil!(a => bitTest(a, j)); if (k == -1) continue; swap(ai[i], ai[k + i]); foreach (l; i + 1..n) { if (bitTest(ai[l], j)) ai[l] ^= ai[i]; } i += 1; } auto r = ai.count!(a => a != 0); writeln(2L ^^ r); }