답안 #304008

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
304008 2020-09-21T00:01:09 Z fadi57 사육제 (CEOI14_carnival) C++14
0 / 100
1 ms 256 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx=160;

int cnt=0;
int par[mx];
int n;
int costume[mx];
int query(int x,int y){
    cout<<x+1;
   for(int i=0;i<x;i++){
       cout<<par[i]+1<<" ";
   }int an;
    cout<<y+1;
    cout<<endl;cin>>an;
    return an;
}

int main() {
cin>>n;

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

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:63:27: warning: 'where' may be used uninitialized in this function [-Wmaybe-uninitialized]
   63 |                 costume[i]=where;
      |                 ~~~~~~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -