#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++){
isCheck[i][i] = 1;
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[parent[i]].empty()) continue;
for(int j=i+1;j<=N;j++){
if(sameSet[parent[j]].empty()) continue;
if(isCheck[parent[i]][parent[j]]) continue;
isCheck[parent[i]][parent[j]] = 1;
isCheck[parent[j]][parent[i]] = 1;
cout << 2 << " " << sameSet[parent[i]].front() << " " << sameSet[parent[j]].front() << endl << flush;
cin >> respon;
if(respon == 1){
moveSet(parent[i], parent[j]);
cntSet--;
break;
}
}
}
}
compressSet();
cout << 0;
for(int i=1;i<=N;i++) cout << " " << parent[i];
cout << endl << flush;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
332 KB |
Output is correct |
2 |
Correct |
19 ms |
332 KB |
Output is correct |
3 |
Partially correct |
52 ms |
384 KB |
Partially correct |
4 |
Partially correct |
72 ms |
548 KB |
Partially correct |
5 |
Correct |
4 ms |
548 KB |
Output is correct |
6 |
Correct |
5 ms |
548 KB |
Output is correct |
7 |
Correct |
19 ms |
624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
624 KB |
Output is correct |
2 |
Correct |
7 ms |
624 KB |
Output is correct |
3 |
Partially correct |
35 ms |
624 KB |
Partially correct |
4 |
Partially correct |
79 ms |
624 KB |
Partially correct |
5 |
Correct |
6 ms |
624 KB |
Output is correct |
6 |
Correct |
11 ms |
624 KB |
Output is correct |
7 |
Correct |
11 ms |
624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
624 KB |
Output is correct |
2 |
Correct |
6 ms |
624 KB |
Output is correct |
3 |
Partially correct |
29 ms |
624 KB |
Partially correct |
4 |
Partially correct |
81 ms |
624 KB |
Partially correct |
5 |
Correct |
15 ms |
624 KB |
Output is correct |
6 |
Correct |
12 ms |
624 KB |
Output is correct |
7 |
Correct |
28 ms |
624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
624 KB |
Output is correct |
2 |
Correct |
7 ms |
624 KB |
Output is correct |
3 |
Partially correct |
79 ms |
624 KB |
Partially correct |
4 |
Partially correct |
40 ms |
624 KB |
Partially correct |
5 |
Partially correct |
31 ms |
624 KB |
Partially correct |
6 |
Partially correct |
42 ms |
624 KB |
Partially correct |
7 |
Correct |
24 ms |
624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
624 KB |
Output is correct |
2 |
Correct |
12 ms |
624 KB |
Output is correct |
3 |
Partially correct |
49 ms |
624 KB |
Partially correct |
4 |
Partially correct |
67 ms |
624 KB |
Partially correct |
5 |
Partially correct |
34 ms |
624 KB |
Partially correct |
6 |
Partially correct |
72 ms |
624 KB |
Partially correct |
7 |
Partially correct |
87 ms |
624 KB |
Partially correct |