結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー nebukuro09nebukuro09
提出日時 2016-11-28 17:05:19
言語 D
(dmd 2.106.1)
結果
RE  
実行時間 -
コード長 1,065 bytes
コンパイル時間 2,851 ms
コンパイル使用メモリ 108,664 KB
実行使用メモリ 35,564 KB
最終ジャッジ日時 2023-09-02 23:11:30
合計ジャッジ時間 20,005 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 556 ms
24,936 KB
testcase_09 AC 113 ms
9,408 KB
testcase_10 AC 421 ms
21,476 KB
testcase_11 AC 305 ms
16,740 KB
testcase_12 AC 649 ms
30,404 KB
testcase_13 AC 718 ms
31,932 KB
testcase_14 AC 402 ms
19,740 KB
testcase_15 AC 786 ms
32,424 KB
testcase_16 AC 637 ms
29,420 KB
testcase_17 AC 719 ms
33,156 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 RE -
testcase_20 AC 409 ms
32,884 KB
testcase_21 AC 847 ms
35,112 KB
testcase_22 AC 828 ms
35,564 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 780 ms
32,532 KB
testcase_34 AC 768 ms
33,956 KB
testcase_35 AC 810 ms
33,624 KB
testcase_36 AC 809 ms
35,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;
import std.bigint;


void main() {
  auto N = readln.chomp.to!int;
  auto A = readln.split.map!(to!long);
  auto M = new int[][](N, 61);
  foreach (i, a; enumerate(A))
    foreach (j; 0..61) 
      M[i][j] = (A[i] >> j) % 2;

  foreach (i; 0..61) {
    //M.each!(writeln);
    //writeln;
    if (M[i][i] == 0) {
      auto mi = i;
      auto m = 60;
      foreach (j; i..N)
        foreach (k; i..61) 
          if (M[j][k] == 1) {
            if (k < m) {
              mi = j;
              m = k;
            }
            break;
          }
      swap(M[i], M[mi]);
    }
    if (M[i][i] == 0) continue;

    foreach (j; i+1..N)
      if (M[j][i] == 1)
        foreach (k; i..61) {
          (M[j][k] ^= M[i][k]);
        }
  }

  int i = N - 1;
  long ans = N;
  while (i >= 0 && M[i].sum == 0) {
    i -= 1;
    ans -= 1;
  }
  writeln(2L^^ans);
}
0