Submission #303559

# Submission time Handle Problem Language Result Execution time Memory
303559 2020-09-20T12:34:26 Z fadi57 Carnival (CEOI14_carnival) C++14
0 / 100
5 ms 2688 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx=1e5+5;
vector<int>v[mx];
int cnt=0;
int par[mx];
int n;
int costume[mx];
int query(int x,int y){
   for(int i=0;i<=x;i++){
       cout<<par[i]<<" ";
   }int an;
    cout<<y;
    cout<<endl;cin>>an;
    return an;
}

int main() {
cin>>n;

if(n==1){
    cout<<0<<" 1";
}else if(n==2){
    cout<<2<<" 1 2"<<endl;
    int x;cin>>x;
    if(x==1){
        cout<<"0 1 1";
    }else{
        cout<<"0 1 2";
    }cout<<endl;
    
}else{
    
        par[0]=1;cnt=0;
        costume[1]=0;
        for(int i=2;i<=n;i++){
            
            
            if(query(cnt,i)==(cnt+2)){
                
                cnt++;costume[i]=cnt;
                par[cnt]=i;
                
            }else{
                
                
                
                int s=0;int end=cnt;ll where;
                while(s<=end){
                    int mid=(s+end)/2;
                 if(query(mid,i)==(mid)+1){
                     end=mid-1;where =mid;
                 }else{
                     s=mid;
                 }
                    
                    
                    
                }
                costume[i]=where;
            }
        }
    }
    
    
cout<<0<<" ";
for(int i=1;i<=n;i++){
    cout<<costume[i]<<" ";
}
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:61:27: warning: 'where' may be used uninitialized in this function [-Wmaybe-uninitialized]
   61 |                 costume[i]=where;
      |                 ~~~~~~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2688 KB Integer 0 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2688 KB Integer 0 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2688 KB Integer 0 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2688 KB Integer 0 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2688 KB Integer 0 violates the range [1, 2]
2 Halted 0 ms 0 KB -