結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー te-shte-sh
提出日時 2016-09-13 13:35:16
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 106 ms / 5,000 ms
コード長 1,085 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 108,828 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2023-09-02 22:05:39
合計ジャッジ時間 4,686 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 1 ms
4,368 KB
testcase_06 AC 1 ms
4,372 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 75 ms
6,448 KB
testcase_09 AC 17 ms
4,368 KB
testcase_10 AC 58 ms
6,236 KB
testcase_11 AC 41 ms
4,368 KB
testcase_12 AC 86 ms
6,936 KB
testcase_13 AC 93 ms
6,732 KB
testcase_14 AC 55 ms
6,456 KB
testcase_15 AC 102 ms
6,936 KB
testcase_16 AC 85 ms
6,616 KB
testcase_17 AC 92 ms
6,856 KB
testcase_18 AC 1 ms
4,372 KB
testcase_19 AC 1 ms
4,368 KB
testcase_20 AC 34 ms
5,432 KB
testcase_21 AC 106 ms
6,996 KB
testcase_22 AC 105 ms
6,932 KB
testcase_23 AC 1 ms
4,372 KB
testcase_24 AC 1 ms
4,368 KB
testcase_25 AC 1 ms
4,372 KB
testcase_26 AC 2 ms
4,368 KB
testcase_27 AC 2 ms
4,372 KB
testcase_28 AC 63 ms
6,040 KB
testcase_29 AC 89 ms
6,508 KB
testcase_30 AC 77 ms
6,856 KB
testcase_31 AC 67 ms
6,968 KB
testcase_32 AC 83 ms
6,460 KB
testcase_33 AC 103 ms
6,992 KB
testcase_34 AC 101 ms
6,724 KB
testcase_35 AC 105 ms
7,056 KB
testcase_36 AC 105 ms
8,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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