QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#568090 | #9310. Permutation Counting 4 | flysky701 | Compile Error | / | / | C++17 | 975b | 2024-09-16 15:12:21 | 2024-09-16 15:12:22 |
Judging History
你现在查看的是最新测评结果
- [2024-09-18 14:56:40]
- hack成功,自动添加数据
- (/hack/835)
- [2024-09-18 14:41:06]
- hack成功,自动添加数据
- (/hack/831)
- [2024-09-17 12:14:52]
- hack成功,自动添加数据
- (/hack/825)
- [2024-09-16 15:12:22]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-09-16 15:12:21]
- 提交
answer
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
using namespace std;
typedef pair<int, int> PII;
vector<int> f;
int find(int x){
if(f[x] != x)
return f[x] = find(f[x]);
return f[x];
}
bool merge(int u, int v){
int u = find(u), v = find(v);
if(u == v)return false;
f[v] = u;
}
void solve()
{
int n;
cin >> n;
f.assign(n + 10, 0);
vector<PII> eg(n + 10);
for (int i = 1; i <= n; i ++){
auto &[l, r] = eg[i];
cin >> l >> r;
l--;
f[i] = i;
}
int ok = 1;
for (int i = 1; i <= n; i ++){
auto [l, r] = eg[i];
if (merge(l, r) == false){
ok = 0;
break;
}
}
if(ok){
cout << 0 << endl;
}else
cout << 1 << endl;
}
signed main(){
ios;
int T;
cin >> T;
while(T --)
solve();
}
详细
answer.code: In function ‘bool merge(int, int)’: answer.code:16:9: error: declaration of ‘int u’ shadows a parameter 16 | int u = find(u), v = find(v); | ^ answer.code:15:16: note: ‘int u’ previously declared here 15 | bool merge(int u, int v){ | ~~~~^ answer.code:16:22: error: declaration of ‘int v’ shadows a parameter 16 | int u = find(u), v = find(v); | ^ answer.code:15:23: note: ‘int v’ previously declared here 15 | bool merge(int u, int v){ | ~~~~^ answer.code:18:10: warning: control reaches end of non-void function [-Wreturn-type] 18 | f[v] = u;