제출 #1165813

#제출 시각아이디문제언어결과실행 시간메모리
1165813SmuggingSpun사육제 (CEOI14_carnival)C++20
20 / 100
26 ms432 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++){ if(i == find_set(i)){ id[i] = ++ID; } } cout << "0 "; for(int i = 1; i <= n; i++){ cout << id[find_set(i)] << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...