Submission #248406

# Submission time Handle Problem Language Result Execution time Memory
248406 2020-07-12T11:27:31 Z LittleFlowers__ Carnival (CEOI14_carnival) C++17
100 / 100
32 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define gg exit(0);

int n;
int ans[10101];

int qry(vector<int> ask){
    cout<<ask.size()<<" ";
    forv(i,ask) cout<<i<<" "; cout<<endl;
    int ret; cin>>ret; return ret;
}

main(){
    #define task "TASK"
    if(fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }

    cin>>n;

    int t=1;
    forinc(i,1,n) if(!ans[i]){
        int j=i;
        for(;;){
            int le=j+1,mi,ri=n,ret=j;
            ans[j]=t;
            while(le<=ri){
                mi=(le+ri)/2;
                vector<int> ask;
                forinc(k,j+1,mi) ask.push_back(k);
                int x=qry(ask);
                ask.push_back(j);
                int y=qry(ask);
                if(x==y){
                    ret=mi, ri=mi-1;
                } else{
                    le=mi+1;
                }
            }
            if(ret==j) break;
            j=ret;
        } t++;
    }
    cout<<"0 ";
    forinc(i,1,n) cout<<ans[i]<<" ";
}

Compilation message

carnival.cpp: In function 'long long int qry(std::vector<long long int>)':
carnival.cpp:10:19: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 #define forv(a,b) for(auto&a:b)
                   ^
carnival.cpp:25:5: note: in expansion of macro 'forv'
     forv(i,ask) cout<<i<<" "; cout<<endl;
     ^~~~
carnival.cpp:25:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     forv(i,ask) cout<<i<<" "; cout<<endl;
                               ^~~~
carnival.cpp: At global scope:
carnival.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
carnival.cpp: In function 'int main()':
carnival.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(task".inp","r",stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 20 ms 384 KB Output is correct
2 Correct 21 ms 384 KB Output is correct
3 Correct 22 ms 384 KB Output is correct
4 Correct 24 ms 384 KB Output is correct
5 Correct 15 ms 384 KB Output is correct
6 Correct 13 ms 384 KB Output is correct
7 Correct 18 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 384 KB Output is correct
2 Correct 20 ms 384 KB Output is correct
3 Correct 18 ms 512 KB Output is correct
4 Correct 25 ms 384 KB Output is correct
5 Correct 23 ms 384 KB Output is correct
6 Correct 23 ms 384 KB Output is correct
7 Correct 17 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 384 KB Output is correct
2 Correct 21 ms 384 KB Output is correct
3 Correct 23 ms 384 KB Output is correct
4 Correct 32 ms 376 KB Output is correct
5 Correct 23 ms 384 KB Output is correct
6 Correct 18 ms 384 KB Output is correct
7 Correct 23 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 384 KB Output is correct
2 Correct 18 ms 384 KB Output is correct
3 Correct 27 ms 384 KB Output is correct
4 Correct 29 ms 384 KB Output is correct
5 Correct 24 ms 384 KB Output is correct
6 Correct 27 ms 384 KB Output is correct
7 Correct 27 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 384 KB Output is correct
2 Correct 23 ms 384 KB Output is correct
3 Correct 29 ms 384 KB Output is correct
4 Correct 30 ms 384 KB Output is correct
5 Correct 23 ms 384 KB Output is correct
6 Correct 28 ms 384 KB Output is correct
7 Correct 28 ms 384 KB Output is correct