# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1165813 | SmuggingSpun | Carnival (CEOI14_carnival) | C++20 | 26 ms | 432 KiB |
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin >> n;
vector<int>parent(n + 1), id(n + 1);
auto find_set = [&] (int N){
while(N != parent[N]){
N = parent[N] = parent[parent[N]];
}
return N;
};
auto merge = [&] (int u, int v){
parent[find_set(v)] = find_set(u);
};
iota(parent.begin(), parent.end(), 0);
for(int i = 1; i < n; i++){
for(int j = i + 1; j <= n; j++){
if(find_set(i) != find_set(j)){
cout << "2 " << i << " " << j << endl;
int x;
cin >> x;
if(x == 1){
merge(i, j);
}
}
}
}
for(int i = 1, ID = 0; i <= n; i++){
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |