Submission #475532

# Submission time Handle Problem Language Result Execution time Memory
475532 2021-09-22T18:31:58 Z Sarah_Mokhtar Carnival (CEOI14_carnival) C++14
100 / 100
19 ms 296 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define read freopen("acpc.in","r",stdin);
#define LESSGO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll N=150,M=505,OO=1e16,mod=1e9+9;
int n,ans[N];
vector<int>cols;
int ask(int l,int r,int i){
    cout<<r-l+1+(i!=-1)<<endl;
    for(int i=l;i<=r;++i) cout<<cols[i]<<' ';
    if(~i) cout<<i<<' ';
    cout<<endl;
    int output; cin>>output;
    return output;
}
int rangeAsk(int l,int r){
    cout<<r-l+1<<endl;
    for(int i=l;i<=r;++i) cout<<i<<' ';
    cout<<endl;
    int output; cin>>output;
    return output;
}
int solve(int l,int r,int i){
    if(l==r){
        return l;
    }
    int mid=(l+r)>>1;
    int a=ask(l,mid,i);
    int b=ask(l,mid,-1);
    if(a==b) return solve(l,mid,i);
    else return solve(mid+1,r,i);
}
int main(){
    cin>>n;
    ans[1]=1;
    cols.push_back(1);
    for(int i=2;i<=n;++i){
        int g=rangeAsk(1,i);
        if(g>cols.size()){
            cols.push_back(i);
            ans[i]=g;
            continue;
        }
        ans[i]=ans[cols[solve(0,cols.size()-1,i)]];
    }
    cout<<0<<" ";
    for(int i=0;i<n;++i){
        cout<<ans[i+1]<<' ';
    }
    cout<<endl;

}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:40:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if(g>cols.size()){
      |            ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 200 KB Output is correct
2 Correct 11 ms 200 KB Output is correct
3 Correct 11 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 8 ms 200 KB Output is correct
6 Correct 4 ms 200 KB Output is correct
7 Correct 7 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 200 KB Output is correct
2 Correct 18 ms 200 KB Output is correct
3 Correct 6 ms 200 KB Output is correct
4 Correct 6 ms 200 KB Output is correct
5 Correct 9 ms 200 KB Output is correct
6 Correct 11 ms 200 KB Output is correct
7 Correct 13 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 200 KB Output is correct
2 Correct 10 ms 200 KB Output is correct
3 Correct 16 ms 200 KB Output is correct
4 Correct 5 ms 296 KB Output is correct
5 Correct 10 ms 200 KB Output is correct
6 Correct 9 ms 200 KB Output is correct
7 Correct 12 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 200 KB Output is correct
2 Correct 7 ms 200 KB Output is correct
3 Correct 10 ms 200 KB Output is correct
4 Correct 4 ms 284 KB Output is correct
5 Correct 14 ms 200 KB Output is correct
6 Correct 11 ms 248 KB Output is correct
7 Correct 7 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 200 KB Output is correct
2 Correct 19 ms 200 KB Output is correct
3 Correct 10 ms 200 KB Output is correct
4 Correct 8 ms 200 KB Output is correct
5 Correct 16 ms 200 KB Output is correct
6 Correct 6 ms 200 KB Output is correct
7 Correct 6 ms 200 KB Output is correct