#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);
}
printf("\n");
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]){
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:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | scanf("%d",&y);
| ~~~~~^~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | scanf("%d",&N);
| ~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
208 KB |
Integer 0 violates the range [1, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
208 KB |
Integer 0 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
208 KB |
Integer 0 violates the range [1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
208 KB |
Integer 0 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
208 KB |
Integer 0 violates the range [1, 2] |
2 |
Halted |
0 ms |
0 KB |
- |