萌新求助CE,本机编译没事

P2713 罗马游戏

```cpp #include <bits/stdc++.h> using namespace std; #define ll long long #define il inline #define reg register const int N = 1000005; int n, m; int fa[N]; bool kill[N]; struct node { int val, ch[2], dist; } t[N]; il int qrint() { int s = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { s = (s << 1) + (s << 3) + (ch ^ 48); ch = getchar(); } return s * f; } int find(int x) {return x == fa[x] ? x : fa[x] = find(fa[x]);} int& rs(int x) {return t[x].ch[t[t[x].ch[1]].dist < t[t[x].ch[0]].dist];} int merge(int x, int y) { if (!x || !y) return x | y; if (t[x].val > t[y].val) swap(x, y); rs(x) = merge(y, rs(x)); t[x].dist = t[rs(x)].dist + 1; return x; } int main() { n = qrint(); for (reg int i = 1; i <= n; ++i) t[i].val = qrint(), fa[i] = i; m = qrint(); while (m--) { char str[5]; scanf("%s", str + 1); if (str[1] == 'M') { int x = qrint(), y = qrint(); int fx = find(x), fy = find(y); if (fx == fy || kill[x] || kill[y]) continue; fa[fx] = fa[fy] = merge(fx, fy); } else { int x = qrint(); if (!kill[x]) { x = find(x); kill[x] = 1; fa[x] = fa[t[x].ch[0]] = fa[t[x].ch[1]] = merge(t[x].ch[0], t[x].ch[1]); printf("%d\n", t[x].val); } else printf("%d\n", 0); } } return 0; } ``` 代码贴二楼
by Kobe303 @ 2022-02-01 14:25:54


用了 ```kill``` 关键字,已经过了,但是这个关键字是什么时候加入的呢?
by Kobe303 @ 2022-02-01 14:34:36


@[Kobe303](/user/292300) `kill` 不是关键字。 `kill` 是 C 库函数。
by Qiaoqia @ 2022-02-01 14:56:26


@[Qiaoqia](/user/499996) 哦,那为什么本机能过呢?
by Kobe303 @ 2022-02-01 14:58:44


这个程序在我本地就报 CE。 ```plain 9:12: error: ‘bool kill [1000005]’ redeclared as different kind of entity 9 | bool kill[N]; | ^ In file included from /usr/include/c++/9/csignal:42, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:43, from /tmp/CP Editor-EftKDt/sol.cpp:1: /usr/include/signal.h:112:12: note: previous declaration ‘int kill(__pid_t, int)’ 112 | extern int kill (__pid_t __pid, int __sig) __THROW; | ^~~~ ```
by Qiaoqia @ 2022-02-01 14:59:02


@[Kobe303](/user/292300) 系统环境或者编译器版本问题?
by Qiaoqia @ 2022-02-01 14:59:32


@[Qiaoqia](/user/499996) 这样子的啊
by Kobe303 @ 2022-02-01 14:59:59


@[Qiaoqia](/user/499996) 大佬别走,还有一个小问题qwq ```cpp int& rs(int x) {return t[x].ch[t[t[x].ch[1]].dist < t[t[x].ch[0]].dist];} ``` 这个 ```&``` 有什么用? 去掉会报错
by Kobe303 @ 2022-02-01 15:02:16


@[Kobe303](/user/292300) ```cpp 35| rs(x) = merge(y, rs(x)); ``` 这一行要求返回值必须是左值引用。~~你是不是没有好好听 cwt 讲课?~~
by Qiaoqia @ 2022-02-01 15:10:12


@[Qiaoqia](/user/499996) 。。。您别这么说(
by Kobe303 @ 2022-02-01 15:12:34


|