Submission #49015

#TimeUsernameProblemLanguageResultExecution timeMemory
49015faishol27Carnival (CEOI14_carnival)C++14
20 / 100
94 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define PUB push_back #define POB pop_back int N, respon, cntSet, bykSet, parent[155]; bool isCheck[155][155]; vector<int>sameSet[155]; void init(){ memset(isCheck, 0, sizeof isCheck); for(int i=1;i<155;i++){ parent[i] = i; sameSet[i].PUB(i); } cntSet = N; cout << N; for(int i=1;i<=N;i++){ cout << " " << i; } cout << endl << flush; cin >> bykSet; } void moveSet(int ke, int dari){ for(int elm:sameSet[dari]){ parent[elm] = ke; sameSet[ke].PUB(elm); } sameSet[dari].clear(); } void compressSet(){ for(int i=1;i<=bykSet;i++){ if(sameSet[i].empty()){ for(int j=i+1;j<=N;j++){ if(!sameSet[j].empty()){ for(int elm:sameSet[j]){ parent[elm] = i; sameSet[i].PUB(elm); } sameSet[j].clear(); break; } } } } } int main(){ cin >> N; init(); while(bykSet != cntSet){ for(int i=1;i<=N;i++){ if(sameSet[i].empty()) continue; for(int j=i+1;j<=N;j++){ if(sameSet[j].empty()) continue; if(isCheck[i][j]) continue; isCheck[i][j] = 1; cout << 2 << " " << sameSet[i].front() << " " << sameSet[j].front() << endl << flush; cin >> respon; if(respon == 1){ moveSet(min(i,j), max(i,j)); cntSet--; } break; } } } compressSet(); cout << 0; for(int i=1;i<=N;i++) cout << " " << parent[i]; cout << endl << flush; }
#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...