結果

問題 No.670 log は定数
ユーザー tnakao0123tnakao0123
提出日時 2018-03-25 17:31:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,025 ms / 4,000 ms
コード長 1,446 bytes
コンパイル時間 3,076 ms
コンパイル使用メモリ 89,412 KB
実行使用メモリ 7,392 KB
最終ジャッジ日時 2023-09-07 11:57:29
合計ジャッジ時間 26,341 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,999 ms
7,248 KB
testcase_01 AC 1,977 ms
7,192 KB
testcase_02 AC 2,007 ms
7,148 KB
testcase_03 AC 2,008 ms
7,392 KB
testcase_04 AC 2,006 ms
7,216 KB
testcase_05 AC 2,017 ms
7,128 KB
testcase_06 AC 2,005 ms
7,172 KB
testcase_07 AC 2,006 ms
7,164 KB
testcase_08 AC 2,002 ms
7,148 KB
testcase_09 AC 2,025 ms
7,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 670.cc: No.670 log は定数 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int PRE = 10000;
const int BN = 16;
const int BITS = 1 << BN;

/* typedef */

typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<ui> vui;

/* global variables */

ull seed;
int acs[BITS + 1];
vui as[BITS];

/* subroutines */

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

/* main */

int main() {
  int n, q;
  scanf("%d%d%lld", &n, &q, &seed);

  for (int i = 0; i < PRE; i++) next();

  for (int i = 0; i < n; i++) {
    ui ai = next();
    ui ab = ai >> BN;
    acs[ab + 1]++;
    as[ab].push_back(ai);
  }
  for (int ab = 0; ab < BITS; ab++) {
    acs[ab + 1] += acs[ab];
    sort(as[ab].begin(), as[ab].end());
  }
  
  ull sum = 0;
  for (int i = 0; i < q; i++) {
    ui x = next();
    ui xb = x >> BN;
    int cnt =
      acs[xb] +
      (lower_bound(as[xb].begin(), as[xb].end(), x) - as[xb].begin());
    sum ^= (ull)cnt * i;
  }

  printf("%llu\n", sum);
  return 0;
}
0