#include<cstdio>
using namespace std;
int N;
int costs[610];
int vis[155] = {};
int cnt = 1;
int party(int l, int r, int x = 0){
printf("%d ",r - l + 1 + (bool) x);
if(x) printf("%d ",x);
for(int i = l;i < r + 1;i++){
printf("%d ",i);
}
fflush(stdout);
int y;
scanf("%d",&y);
return y;
}
void fillCosts(int v = 1, int tl = 1, int tr = N){
if(tl == tr) return;
costs[v] = party(tl, tr);
int tm = (tl + tr) / 2;
fillCosts(v * 2, tl, tm);
fillCosts(v * 2 + 1, tm + 1, tr);
}
void travCosts(int x, int v = 1, int tl = 1, int tr = N){
if(tr <= x){
return;
}
if(tl == tr){
if(party(tl, tl, x) == 1) vis[tl] = cnt;
return;
}
if(tl > x && party(tl, tr, x) != costs[v]) return;
int tm = (tl + tr) / 2;
travCosts(x, v * 2, tl, tm);
travCosts(x, v * 2 + 1, tm + 1, tr);
}
int main(){
scanf("%d",&N);
fillCosts();
for(int i = 1;i < N + 1;i++){
if(!vis[i]){
vis[i] = cnt;
travCosts(i);
cnt++;
}
}
printf("0 ");
for(int i = 1;i < N + 1;i++){
printf("%d ",vis[i]);
}
}
Compilation message
carnival.cpp: In function 'int party(int, int, int)':
carnival.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%d",&y);
| ~~~~~^~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | scanf("%d",&N);
| ~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
208 KB |
Output is correct |
2 |
Correct |
9 ms |
208 KB |
Output is correct |
3 |
Correct |
10 ms |
208 KB |
Output is correct |
4 |
Correct |
8 ms |
276 KB |
Output is correct |
5 |
Correct |
7 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
11 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
208 KB |
Output is correct |
2 |
Correct |
16 ms |
208 KB |
Output is correct |
3 |
Correct |
6 ms |
208 KB |
Output is correct |
4 |
Correct |
6 ms |
208 KB |
Output is correct |
5 |
Correct |
7 ms |
208 KB |
Output is correct |
6 |
Correct |
7 ms |
208 KB |
Output is correct |
7 |
Correct |
10 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
9 ms |
256 KB |
Output is correct |
3 |
Correct |
13 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
5 |
Correct |
8 ms |
208 KB |
Output is correct |
6 |
Correct |
8 ms |
208 KB |
Output is correct |
7 |
Correct |
7 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
208 KB |
Output is correct |
2 |
Correct |
8 ms |
208 KB |
Output is correct |
3 |
Correct |
10 ms |
208 KB |
Output is correct |
4 |
Correct |
8 ms |
208 KB |
Output is correct |
5 |
Correct |
9 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
10 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
208 KB |
Output is correct |
2 |
Correct |
14 ms |
208 KB |
Output is correct |
3 |
Correct |
9 ms |
208 KB |
Output is correct |
4 |
Correct |
5 ms |
208 KB |
Output is correct |
5 |
Correct |
9 ms |
208 KB |
Output is correct |
6 |
Correct |
11 ms |
208 KB |
Output is correct |
7 |
Correct |
11 ms |
208 KB |
Output is correct |