結果

問題 No.670 log は定数
ユーザー SHIJOUSHIJOU
提出日時 2020-09-01 03:40:17
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1,499 ms / 4,000 ms
コード長 1,298 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 30,976 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 13:57:36
合計ジャッジ時間 17,294 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,425 ms
5,248 KB
testcase_01 AC 1,432 ms
5,376 KB
testcase_02 AC 1,426 ms
5,376 KB
testcase_03 AC 1,443 ms
5,376 KB
testcase_04 AC 1,459 ms
5,376 KB
testcase_05 AC 1,499 ms
5,376 KB
testcase_06 AC 1,454 ms
5,376 KB
testcase_07 AC 1,457 ms
5,376 KB
testcase_08 AC 1,457 ms
5,376 KB
testcase_09 AC 1,440 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAXN 200010
#define N 0x7fffffff/MAXN+2

int compareInt(const void* a, const void* b);
int next();

unsigned long long seed;
int a[MAXN];
int b[N];
int place[N];

int main() {
  int n, q;
  scanf("%d%d%llu", &n, &q, &seed);
  for(int i = 0; i < 10000; i++) next();

  for(int i = 0; i < n; i++) a[i] = next();
  qsort(a, n, sizeof(int), compareInt);
  memset(place, -1, sizeof(place));
  for(int i = 0; i < n; i++) {
    int now = a[i]/MAXN;
    b[now+1]++;
    if(place[now] == -1) place[now] = i;
  }
  for(int i = 1; i < N; i++) {
    b[i] += b[i-1];
  }
  for(int i = N-2; i >= 0; i--) {
    if(place[i] == -1) place[i] = place[i+1];
  }

  long long ans = 0;
  for(int i = 0; i < q; i++) {
    int x = next();
    int now = x/MAXN;
    long long ima = b[now];
    for(int j = place[now]; j < n; j++) {
      if(a[j] >= x) break;
      ima++;
    }
    ans ^= ima*i;
  }
  printf("%lld\n", ans);
  return 0;
}


int compareInt(const void* a, const void* b) {
  int aNum = *(int*)a;
  int bNum = *(int*)b;
  if( aNum < bNum ){
    return -1;
  }
  else if( aNum > bNum ){
    return 1;
  }
  return 0;
}

int next() {
  seed = seed ^ (seed << 13);
  seed = seed ^ (seed >> 7);
  seed = seed ^ (seed << 17);
  return (seed >> 33);
}
0