记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 4ms 1.457 MiB
#2 Accepted 4ms 1.324 MiB
#3 Accepted 4ms 1.367 MiB
#4 Accepted 4ms 1.469 MiB
#5 Accepted 4ms 1.449 MiB
#6 Accepted 49ms 10.84 MiB
#7 Accepted 52ms 11.293 MiB
#8 Accepted 41ms 10.758 MiB
#9 Accepted 47ms 11.555 MiB
#10 Accepted 45ms 11.316 MiB
#11 Accepted 731ms 109.383 MiB
#12 Accepted 682ms 103.934 MiB
#13 Accepted 735ms 108.383 MiB
#14 Accepted 747ms 110.027 MiB
#15 Accepted 777ms 113.438 MiB
#16 Accepted 4286ms 493.957 MiB
#17 Accepted 4690ms 535.348 MiB
#18 Accepted 4639ms 530.012 MiB
#19 Accepted 3970ms 464.68 MiB
#20 Accepted 3858ms 469.633 MiB

代码

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast",3,"inline")
using namespace std;
int seed, n;
int rnd() { return seed = (seed * 19260817ll + 20230853) & INT_MAX; }
const int N = 5e7 + 9, M = 1 << 26;
int a[N], zkw[1 << 27];
int bpos[N];
int tot, mx;
inline void push(int x) {
  a[++tot] = x;
  zkw[M + tot] = tot;
  for (int pos = M + tot; pos & 1; pos >>= 1)
    zkw[pos >> 1] = a[zkw[pos]] < a[zkw[pos ^ 1]] ? zkw[pos] : zkw[pos ^ 1];
  if (a[mx] > x) mx = tot;
}
inline int top() { return a[mx]; }
inline void pop() {
  a[mx] = INT_MAX;
  for (int pos = M + mx; zkw[pos >> 1]; pos >>= 1)
    zkw[pos >> 1] = a[zkw[pos]] < a[zkw[pos ^ 1]] ? zkw[pos] : zkw[pos ^ 1];
  for (int x = tot + 1; x; x &= x - 1) {
    int tmpmx = zkw[bpos[x]];
    if (a[mx] > a[tmpmx]) mx = tmpmx;
  }
}
int main() {
  cin >> n >> seed;
  int ans = 0;
  a[0] = INT_MAX;
  for (int i = 1; i <= n; ++i) {
    int w = i + M;
    while (w & 1) w >>= 1;
    bpos[i + 1] = w;
  }
  for (int i = 1; i <= (n >> 1); ++i) push(rnd());
  for (int i = 1; i <= (n >> 1); ++i) {
    switch (rnd() % 3) {
      case 0:
        push(rnd());
        break;
      case 1:
        pop();
        break;
      default:
        ans ^= top();
    }
  }
  cout << ans << endl;
  return 0;
}

信息

递交者
类型
递交
题目
P1004 Heaptester
语言
C++
递交时间
2021-01-10 10:27:35
评测时间
2021-01-10 10:27:35
评测机
分数
100
总耗时
25379ms
峰值内存
535.348 MiB