记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 4ms 460.0 KiB
#2 Accepted 4ms 468.0 KiB
#3 Accepted 4ms 508.0 KiB
#4 Accepted 4ms 476.0 KiB
#5 Accepted 4ms 496.0 KiB
#6 Accepted 34ms 2.062 MiB
#7 Accepted 36ms 2.133 MiB
#8 Accepted 34ms 2.039 MiB
#9 Accepted 37ms 2.188 MiB
#10 Accepted 36ms 2.141 MiB
#11 Accepted 547ms 18.484 MiB
#12 Accepted 518ms 17.582 MiB
#13 Accepted 538ms 18.32 MiB
#14 Accepted 547ms 18.586 MiB
#15 Accepted 563ms 19.168 MiB
#16 Accepted 3086ms 82.582 MiB
#17 Accepted 3377ms 89.484 MiB
#18 Accepted 3346ms 88.582 MiB
#19 Accepted 2865ms 77.695 MiB
#20 Accepted 2773ms 78.52 MiB

代码

#include <bits/stdc++.h>
using namespace std;
int seed, n;
int rnd() { return seed = (seed * 19260817ll + 20230853) & INT_MAX; }
const int N = 1e8 + 9;
int hp[N];
int tot;
inline void push(int x) {
  hp[++tot] = x;
  for (int w = tot; hp[w] < hp[w >> 1]; w >>= 1) swap(hp[w], hp[w >> 1]);
}
inline void pop() {
  swap(hp[1], hp[tot--]);
  int pos = 1;
  while (1) {
    if ((pos << 1) > tot) break;
    int* a = hp + (pos << 1);
    if ((pos << 1 | 1) <= tot && *a > *(a + 1)) ++a;
    if (hp[pos] < *a) break;
    swap(hp[pos], *a);
    pos = a - hp;
  }
}
inline int top() { return hp[1]; }
int main() {
  cin >> n >> seed;
  int ans = 0;
  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++
递交时间
2020-12-20 09:01:13
评测时间
2021-01-10 10:16:25
评测机
分数
100
总耗时
18364ms
峰值内存
89.484 MiB