记录详情

Accepted

/in/foo.cc: In function 'void pop()':
/in/foo.cc:22:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int tmpmx = zkw[(M + x >> ((x & 0xffff) ? __ffs[(x & 0xffff)]
                      ~~^~~
# 状态 耗时 内存占用
#1 Accepted 4ms 1.344 MiB
#2 Accepted 4ms 1.207 MiB
#3 Accepted 5ms 1.309 MiB
#4 Accepted 6ms 1.285 MiB
#5 Accepted 6ms 1.316 MiB
#6 Accepted 44ms 7.582 MiB
#7 Accepted 45ms 7.801 MiB
#8 Accepted 40ms 7.531 MiB
#9 Accepted 44ms 8.09 MiB
#10 Accepted 43ms 7.914 MiB
#11 Accepted 735ms 73.273 MiB
#12 Accepted 687ms 69.688 MiB
#13 Accepted 727ms 72.566 MiB
#14 Accepted 741ms 73.684 MiB
#15 Accepted 772ms 76.016 MiB
#16 Accepted 4272ms 329.672 MiB
#17 Accepted 4685ms 357.277 MiB
#18 Accepted 4634ms 353.691 MiB
#19 Accepted 3970ms 310.102 MiB
#20 Accepted 3833ms 313.398 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, M = 1 << 26;
int a[N], zkw[1 << 27];
int __ffs[1 << 16];
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[(M + x >> ((x & 0xffff) ? __ffs[(x & 0xffff)]
                                            : __ffs[x >> 16] + 16)) -
                    1];
    if (a[mx] > a[tmpmx]) mx = tmpmx;
  }
}
int main() {
  cin >> n >> seed;
  int ans = 0;
  a[0] = INT_MAX;
  for (int i = 1; i < (1 << 16); ++i)
    __ffs[i] = (i & 1) ? 0 : (__ffs[i >> 1] + 1);
  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-19 23:13:08
评测时间
2021-01-10 10:17:10
评测机
分数
100
总耗时
25305ms
峰值内存
357.277 MiB