Compile Error
/tmp/cc6fkLfr.o: In function `rnd()': foo.cc:(.text+0x2): relocation truncated to fit: R_X86_64_PC32 against symbol `seed' defined in .bss section in /tmp/cc6fkLfr.o foo.cc:(.text+0x16): relocation truncated to fit: R_X86_64_PC32 against symbol `seed' defined in .bss section in /tmp/cc6fkLfr.o /tmp/cc6fkLfr.o: In function `main': foo.cc:(.text.startup+0x14): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/cc6fkLfr.o foo.cc:(.text.startup+0x22): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc6fkLfr.o foo.cc:(.text.startup+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/cc6fkLfr.o foo.cc:(.text.startup+0x34): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/cc6fkLfr.o foo.cc:(.text.startup+0x3a): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc6fkLfr.o foo.cc:(.text.startup+0x87): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc6fkLfr.o foo.cc:(.text.startup+0x94): relocation truncated to fit: R_X86_64_PC32 against symbol `tot' defined in .bss section in /tmp/cc6fkLfr.o foo.cc:(.text.startup+0x9e): relocation truncated to fit: R_X86_64_PC32 against symbol `rt' defined in .bss section in /tmp/cc6fkLfr.o foo.cc:(.text.startup+0xa8): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
代码
#include <bits/stdc++.h>
using namespace std;
int seed, n;
int rnd() { return seed = (seed * 19260817ll + 20230853) & INT_MAX; }
const int N = 2e8 + 20, inf = INT_MAX, K = 90;
int rt, rth = 1, tot, mn = inf, mnb = 2;
int f[N], l[N], r[N], v[N], cnt[N], ch[N][2];
bool ok[N];
inline void pup(int x) { v[x] = max(v[ch[x][0]], v[ch[x][1]]); }
inline bool meg(int ls, int rs) {
if (f[ls]) {
ch[f[ls]][0] = ls;
ch[f[ls]][1] = rs;
f[rs] = f[ls];
pup(f[ls]);
} else if (f[rs]) {
ch[f[rs]][0] = ls;
ch[f[rs]][1] = rs;
f[ls] = f[rs];
pup(f[rs]);
} else {
int x = f[r[rs]];
r[++tot] = x;
l[tot] = l[x];
r[l[x]] = tot;
l[x] = tot;
f[ls] = f[rs] = tot;
ch[tot][0] = ls;
ch[tot][1] = rs;
v[tot] = max(v[ls], v[rs]);
return 0;
}
return 1;
}
inline void push(int x) {
int now = rt, nh = rth, op1, op2;
op1 = (nh << 1) - 1;
while (nh > 1) {
l[now] = op1;
r[op1] = now;
if (mn > v[ch[now][0]]) {
if (now == rt) {
r[op1] = op1 + 1;
l[op1 + 1] = op1;
rt = ch[now][1];
f[rt] = 0;
rth--;
}
ch[now][0] = 0;
ok[ch[now][1]] = 0;
now = ch[now][1];
} else
now = ch[now][0];
nh--;
op1 -= 2;
}
l[now] = 1;
r[1] = now;
now = rt, nh = rth;
while (nh > 1) {
now = ch[now][(x > v[ch[now][0]])];
nh--;
}
if (x == v[now]) {
cnt[now]++;
return;
}
r[++tot] = now;
l[tot] = l[now];
r[l[now]] = tot;
l[now] = tot;
v[tot] = x;
cnt[tot] = 1;
if (x < mn) {
mn = x;
mnb = tot;
}
now = tot;
nh = 1;
while (1) {
op1 = l[now];
op2 = r[now];
if (!ok[op1]) {
ok[now] = ok[op1] = 1;
if (meg(op1, now)) {
while (now != rt) {
now = f[now];
pup(now);
}
return;
}
} else if (!ok[op2]) {
ok[now] = ok[op2] = 1;
if (meg(now, op2)) return;
} else if (f[op1] == f[op2]) {
ch[f[op1]][0] = 0;
f[now] = f[op1] = 0;
meg(op1, now);
ok[now] = ok[op1] = 1;
ok[op2] = 0;
} else if (op1 > K || op2 > K) {
meg(now, now);
} else {
rt = now;
rth = nh;
return;
}
now = f[now];
nh++;
}
}
inline int top() { return mn; }
inline void pop() {
if (--cnt[mnb] > 0) return;
mnb = r[mnb];
mn = v[mnb];
}
int main() {
v[0] = -inf;
for (int i = 1; i <= K; ++i) {
f[i] = i + 2;
ok[i] = 1;
if (i & 1) {
r[i] = i + 1;
v[i] = -inf;
} else {
l[i] = i - 1;
v[i] = inf;
}
}
rt = tot = K + 1;
v[rt] = inf;
l[rt] = 1;
r[rt] = 2;
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:11:45
- 评测时间
- 2020-12-20 09:11:50
- 评测机
- 分数
- 0
- 总耗时
- 0ms
- 峰值内存
- 0 Bytes