답안 #475527

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
475527 2021-09-22T18:27:37 Z Sarah_Mokhtar 사육제 (CEOI14_carnival) C++14
0 / 100
3 ms 200 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<<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)]];
    }
    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()){
      |            ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 200 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -