답안 #43403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43403 2018-03-15T20:16:10 Z Hassoony 사육제 (CEOI14_carnival) C++14
0 / 100
4 ms 2412 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MX=1e5+9;
int n,p[MX];
int find(int x){
    if(x==p[x])return x;
    return p[x]=find(p[x]);
}
map<int,int>hashy;
void merge_(int x,int y){
    x=find(x);
    y=find(y);
    p[y]=x;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)p[i]=i;
    for(int i=1;i<=n;i++){
        vector<int>v;
        for(int j=1;j<i;j++){
            if(j==find(j))v.push_back(j);
        }
        cout<<v.size()+1<<" "<<i<<" ";
        for(auto pp:v)cout<<pp<<" ";
        cout<<endl;
        int x;
        scanf("%d",&x);
        if(x==v.size()+1)continue;
        int l=0,r=v.size()-1,ans=0;
        while(l<=r){
            int mid=(l+r)/2;
            cout<<mid-l+2<<" "<<i<<" ";
            for(int j=l;j<=mid;j++)cout<<v[j]<<" ";
            cout<<endl;
            scanf("%d",&x);
            if(x==mid-l+2){
                ans=mid+1;
                l=mid+1;
            }
            else r=mid-1;
        }
        merge_(i,v[ans]);
    }
    for(int i=1;i<=n;i++){
        hashy[p[i]]=1;
    }
    int tt=0;
    for(auto pp:hashy){
        hashy[pp.first]=++tt;
    }
    cout<<0<<" ";
    for(int i=1;i<n;i++)cout<<hashy[p[i]]<<" ";
    cout<<hashy[p[n]]<<endl;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:30:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(x==v.size()+1)continue;
             ^
carnival.cpp:18:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
carnival.cpp:29:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
                       ^
carnival.cpp:37:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&x);
                           ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2412 KB Integer 12 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2412 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2412 KB Integer 2 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2412 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2412 KB Integer 3 violates the range [1, 2]
2 Halted 0 ms 0 KB -