#include <bits/stdc++.h>
#define forn(i,n) for(int i =0;i<int(n);i++)
#define nfor(i,n) for(int i =int(n)-1;i>=0;i--)
#define rep(i,j,n) for(int i = int(j);i <= int(n);i++)
#define rev(i,j,n) for(int i = int(j);i>=int(n);i--)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define oo 2000000000
#define ooo 2000000000000000000
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
const int N = 100010,MOD = 1000000007;
const double PI = acos(-1.0);
int gcd(int a,int b){return (b==0) ? a : gcd(b,a%b);}
string tostr(ll num){string res = "";while (num)res += char('0' + (num % 10)),num/=10;reverse(all(res));return res;}
string tobin(int num){string res="";while(num)res += char('0' + (num % 2)),num/=2;reverse(all(res));return res;}
ll tonum(string te){ll res = 0;forn(i,te.size())res *= 10LL,res += te[i]-'0';return res;}
int bit(vector <ll> &v,ll a,ll b){return upper_bound(all(v),b)-upper_bound(all(v),a-1);}
void fl(){fflush(stdout);}
int n,ans[155],cnt= 1;
int ask(int left,int right){
if (left >= right){
return 1;
}
printf("%d",right-left+1);
rep(i,left,right)
printf(" %d",i);
cout<<endl;
int res;
scanf("%d",&res);
return res;
}
int main(){
memset(ans,-1,sizeof ans);
scanf("%d",&n);
for (int i = 1;i<=n;i++){
if (ans[i] == -1)
ans[i] = cnt++;
if (ask(i,n) != ask(i+1,n)){
continue;
}
int low = i+1,high = n,res = i;
while (low <= high){
int md = (low + high) / 2;
if (ask(i,md) == ask(i + 1,md)){
res = md;
high = md - 1;
}
else
low = md + 1;
}
ans[res] = ans[i];
}
printf("0");
rep(i,1,n)
printf(" %d",ans[i]);
return 0;
}
Compilation message
carnival.cpp: In function 'int ask(int, int)':
carnival.cpp:38:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&res);
^
carnival.cpp: In function 'int main()':
carnival.cpp:44:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
2016 KB |
Output is correct |
2 |
Correct |
19 ms |
2016 KB |
Output is correct |
3 |
Correct |
9 ms |
2016 KB |
Output is correct |
4 |
Correct |
9 ms |
2016 KB |
Output is correct |
5 |
Correct |
16 ms |
2016 KB |
Output is correct |
6 |
Correct |
16 ms |
2016 KB |
Output is correct |
7 |
Correct |
6 ms |
2016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2016 KB |
Output is correct |
2 |
Correct |
3 ms |
2016 KB |
Output is correct |
3 |
Correct |
6 ms |
2016 KB |
Output is correct |
4 |
Correct |
19 ms |
2016 KB |
Output is correct |
5 |
Correct |
9 ms |
2016 KB |
Output is correct |
6 |
Correct |
13 ms |
2016 KB |
Output is correct |
7 |
Correct |
9 ms |
2016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
2016 KB |
Output is correct |
2 |
Correct |
33 ms |
2016 KB |
Output is correct |
3 |
Correct |
6 ms |
2016 KB |
Output is correct |
4 |
Correct |
9 ms |
2016 KB |
Output is correct |
5 |
Correct |
13 ms |
2016 KB |
Output is correct |
6 |
Correct |
3 ms |
2016 KB |
Output is correct |
7 |
Correct |
9 ms |
2016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
2016 KB |
Output is correct |
2 |
Correct |
16 ms |
2016 KB |
Output is correct |
3 |
Correct |
23 ms |
2016 KB |
Output is correct |
4 |
Correct |
6 ms |
2016 KB |
Output is correct |
5 |
Correct |
23 ms |
2016 KB |
Output is correct |
6 |
Correct |
13 ms |
2016 KB |
Output is correct |
7 |
Correct |
16 ms |
2016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
2016 KB |
Output is correct |
2 |
Correct |
13 ms |
2016 KB |
Output is correct |
3 |
Correct |
9 ms |
2016 KB |
Output is correct |
4 |
Correct |
3 ms |
2016 KB |
Output is correct |
5 |
Correct |
9 ms |
2016 KB |
Output is correct |
6 |
Correct |
3 ms |
2016 KB |
Output is correct |
7 |
Correct |
6 ms |
2016 KB |
Output is correct |