結果

問題 No.670 log は定数
ユーザー Min_25Min_25
提出日時 2018-03-23 22:44:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,817 ms / 4,000 ms
コード長 1,847 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 88,392 KB
実行使用メモリ 4,452 KB
最終ジャッジ日時 2023-09-07 03:17:14
合計ジャッジ時間 21,435 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,812 ms
4,376 KB
testcase_01 AC 1,808 ms
4,380 KB
testcase_02 AC 1,798 ms
4,380 KB
testcase_03 AC 1,792 ms
4,376 KB
testcase_04 AC 1,803 ms
4,380 KB
testcase_05 AC 1,811 ms
4,376 KB
testcase_06 AC 1,817 ms
4,380 KB
testcase_07 AC 1,806 ms
4,452 KB
testcase_08 AC 1,801 ms
4,376 KB
testcase_09 AC 1,803 ms
4,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstring>

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <stack>
#include <queue>

#include <tuple>
 
#define getchar getchar_unlocked
#define putchar putchar_unlocked
 
#define _rep(_1, _2, _3, _4, name, ...) name
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, c) for (int i = int(a); i < int(b); i += int(c))
#define rep(...) _rep(__VA_ARGS__, rep4, rep3, rep2, _)(__VA_ARGS__)
 
using namespace std;
 
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f80 = long double;
 
int get_int() {
  int n, c, sign = 0;
  while ((c = getchar()) < '-');
  if (c == '-') sign = 1, n = 0;
  else n = c - '0';
  while ((c = getchar()) >= '0') n = n * 10 + c - '0';
  return sign ? -n : n;
}

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

void solve() {
  int N, Q;
  while (~scanf("%d %d %llu", &N, &Q, &seed)) {
    rep(i, 1e4) next();
    vector<int> a(N);
    rep(i, N) a[i] = next();
    sort(a.begin(), a.end());
    int shift = 16, b = 1 << shift;
    vector<int> ofs(b + 1);
    int o = 0;
    for (int i = 0; i < b; ++i) {
      while (o < N && (a[o] >> shift) <= i) ++o;
      ofs[i + 1] = o;
    }
    int *p = a.data();
    i64 ans = 0;
    for (int qi = 0; qi < Q; ++qi) {
      int x = next();
      int b = x >> shift;
      int res = lower_bound(p + ofs[b], p + ofs[b + 1], x) - p;
      ans ^= i64(res) * qi;
    }
    printf("%lld\n", ans);
  }
}

int main() {
  clock_t beg = clock();
  solve();
  clock_t end = clock();
  fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC);
  return 0;
}
0