結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー nebukuro09nebukuro09
提出日時 2016-11-28 17:21:18
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 418 ms / 5,000 ms
コード長 1,234 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 114,440 KB
実行使用メモリ 36,504 KB
最終ジャッジ日時 2023-09-02 23:12:14
合計ジャッジ時間 9,018 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 270 ms
27,032 KB
testcase_09 AC 48 ms
9,248 KB
testcase_10 AC 191 ms
20,652 KB
testcase_11 AC 134 ms
15,540 KB
testcase_12 AC 339 ms
31,956 KB
testcase_13 AC 349 ms
32,884 KB
testcase_14 AC 231 ms
20,120 KB
testcase_15 AC 368 ms
34,396 KB
testcase_16 AC 292 ms
31,708 KB
testcase_17 AC 308 ms
32,532 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 11 ms
5,244 KB
testcase_21 AC 406 ms
36,504 KB
testcase_22 AC 391 ms
35,768 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 204 ms
24,700 KB
testcase_29 AC 354 ms
32,728 KB
testcase_30 AC 348 ms
29,480 KB
testcase_31 AC 247 ms
24,636 KB
testcase_32 AC 356 ms
32,708 KB
testcase_33 AC 361 ms
35,012 KB
testcase_34 AC 373 ms
35,000 KB
testcase_35 AC 386 ms
35,656 KB
testcase_36 AC 418 ms
35,584 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;
  readln;
  auto A = readln.split.map!(to!long).array.sort.uniq.array;
  auto N = A.length.to!int;
  auto M = new int[][](N, 61);
  foreach (i, a; enumerate(A))
    foreach (j; 0..61) 
      M[i][j] = (A[i] >> j) % 2;

  auto step = 0;
  foreach (i; 0..min(61,N)) {
    //M.each!(writeln);
    //writeln;
    if (M[i][i] == 0) {
      auto mi = i;
      auto m = 60;
      foreach (j; i+step..N)
        foreach (k; i..61) 
          if (M[j][k] == 1) {
            if (k < m) {
              mi = j;
              m = k;
            }
            break;
          }
      swap(M[i], M[mi]);
      foreach (j; 0..N)
        swap(M[j][i], M[j][m]);
    }
    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]);
        }
  }

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