#include<bits/stdc++.h>
#define maxn 160
int resp[maxn];
using namespace std;
int teste(int cur,int ini,int fim){
vector<int> t;
for(int i=ini;i<=fim;i++){
if(resp[i]==0&&i!=cur&&i!=-cur){
t.push_back(i);
}
}
if(cur>0) t.push_back(cur);
if(t.size()==1) return 1;
cout<<t.size()<<" ";
for(int i=0;i<t.size();i++){
cout<<t[i]<<" ";
}
cout<<endl;
int resp;
cin>>resp;
return resp;
}
void findc(int cur,int ini,int fim){
int r1=0,r2=0;
r1=teste(cur,ini,fim);
if(r1==1){
for(int i=ini;i<=fim;i++){
if(resp[i]==0) resp[i]=resp[cur];
}
}
else r2=teste(-cur,ini,fim);
if(r1==r2){
int m=(ini+fim)/2;
findc(cur,ini,m);
findc(cur,m+1,fim);
}
}
int main(){
int n;
cin>>n;
int c=1;
for(int i=1;i<=n;i++){
if(resp[i]==0){
resp[i]=c;
findc(i,1,n);
c++;
}
}
cout<<"0"<<" ";
for(int i=1;i<=n;i++){
cout<<resp[i]<<" ";
}
}
Compilation message
carnival.cpp: In function 'int teste(int, int, int)':
carnival.cpp:15:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<t.size();i++){
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
376 KB |
Output is correct |
2 |
Correct |
22 ms |
376 KB |
Output is correct |
3 |
Correct |
20 ms |
248 KB |
Output is correct |
4 |
Correct |
9 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
20 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
376 KB |
Output is correct |
2 |
Correct |
19 ms |
376 KB |
Output is correct |
3 |
Correct |
14 ms |
376 KB |
Output is correct |
4 |
Correct |
12 ms |
376 KB |
Output is correct |
5 |
Correct |
8 ms |
376 KB |
Output is correct |
6 |
Correct |
8 ms |
248 KB |
Output is correct |
7 |
Correct |
16 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
15 ms |
252 KB |
Output is correct |
3 |
Correct |
28 ms |
376 KB |
Output is correct |
4 |
Correct |
9 ms |
380 KB |
Output is correct |
5 |
Correct |
9 ms |
248 KB |
Output is correct |
6 |
Correct |
4 ms |
248 KB |
Output is correct |
7 |
Correct |
15 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
248 KB |
Output is correct |
2 |
Correct |
12 ms |
248 KB |
Output is correct |
3 |
Correct |
15 ms |
248 KB |
Output is correct |
4 |
Correct |
8 ms |
248 KB |
Output is correct |
5 |
Correct |
6 ms |
248 KB |
Output is correct |
6 |
Correct |
7 ms |
252 KB |
Output is correct |
7 |
Correct |
23 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Output is correct |
2 |
Correct |
21 ms |
296 KB |
Output is correct |
3 |
Correct |
22 ms |
248 KB |
Output is correct |
4 |
Correct |
19 ms |
248 KB |
Output is correct |
5 |
Correct |
11 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
7 ms |
248 KB |
Output is correct |