結果

問題 No.5001 排他的論理和でランニング
ユーザー letrangerjpletrangerjp
提出日時 2018-03-24 18:09:01
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 274 ms / 1,500 ms
コード長 979 bytes
コンパイル時間 106 ms
実行使用メモリ 6,148 KB
スコア 52,428,750
最終ジャッジ日時 2020-03-12 20:22:22
ジャッジサーバーID
(参考情報)
judge9 /
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
5,380 KB
testcase_01 AC 3 ms
5,384 KB
testcase_02 AC 7 ms
5,380 KB
testcase_03 AC 41 ms
5,380 KB
testcase_04 AC 46 ms
5,376 KB
testcase_05 AC 25 ms
5,380 KB
testcase_06 AC 274 ms
5,380 KB
testcase_07 AC 99 ms
5,384 KB
testcase_08 AC 245 ms
5,380 KB
testcase_09 AC 10 ms
5,380 KB
testcase_10 AC 155 ms
5,380 KB
testcase_11 AC 154 ms
5,380 KB
testcase_12 AC 50 ms
5,384 KB
testcase_13 AC 94 ms
5,380 KB
testcase_14 AC 25 ms
5,380 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 117 ms
5,380 KB
testcase_17 AC 220 ms
5,380 KB
testcase_18 AC 127 ms
5,380 KB
testcase_19 AC 52 ms
5,380 KB
testcase_20 AC 31 ms
5,380 KB
testcase_21 AC 204 ms
5,376 KB
testcase_22 AC 62 ms
5,376 KB
testcase_23 AC 114 ms
5,376 KB
testcase_24 AC 20 ms
5,380 KB
testcase_25 AC 48 ms
5,376 KB
testcase_26 AC 66 ms
6,148 KB
testcase_27 AC 21 ms
5,380 KB
testcase_28 AC 24 ms
5,380 KB
testcase_29 AC 29 ms
5,380 KB
testcase_30 AC 156 ms
5,380 KB
testcase_31 AC 23 ms
5,376 KB
testcase_32 AC 24 ms
5,380 KB
testcase_33 AC 57 ms
5,384 KB
testcase_34 AC 96 ms
5,376 KB
testcase_35 AC 66 ms
5,380 KB
testcase_36 AC 23 ms
5,376 KB
testcase_37 AC 86 ms
5,380 KB
testcase_38 AC 44 ms
5,380 KB
testcase_39 AC 103 ms
5,380 KB
testcase_40 AC 43 ms
5,380 KB
testcase_41 AC 10 ms
5,380 KB
testcase_42 AC 38 ms
5,376 KB
testcase_43 AC 162 ms
5,380 KB
testcase_44 AC 87 ms
5,380 KB
testcase_45 AC 29 ms
5,380 KB
testcase_46 AC 95 ms
5,376 KB
testcase_47 AC 15 ms
5,380 KB
testcase_48 AC 26 ms
5,380 KB
testcase_49 AC 27 ms
5,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

static unsigned long y = 2463534242;
unsigned long xorshift(void) {
  y = y ^ (y << 13); y = y ^ (y >> 17);
  return y = y ^ (y << 5);
}

int main(void) {
  y = time(NULL);
  int N, M, A[100000], used[100000] = {0};
  scanf("%d%d\n", &N, &M);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }

  int curr = 0;
  for (int i = 0; i < M; ++i) {
    curr ^= A[i];
    used[i] = 1;
  }
  for (int i = 0; i < 10000000; ++i) {
    int from, to;
    do { from = xorshift()%N; } while(!used[from]);
    used[from] = 0;
    do { to = xorshift()%N; } while(used[to]);
    used[to] = 1;
    curr ^= A[from] ^ A[to];
    if (curr == (1<<20) - 1) {
      break;
    }
  }
  // printf("%d\n", curr);
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (used[i] != 0) {
      printf("%d", A[i]);
      ++cnt;
      if (cnt < M) {
        putchar(' ');
      } else {
        putchar('\n');
        break;
      }
    }
  }
}
0