답안 #43399

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

using namespace std;
typedef long long ll;
const int MX=155;
int n,p[MX],vis[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<<" ";
        cout<<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<<" ";
            for(int j=l;j<=mid;j++)cout<<v[j]<<" ";
            cout<<i<<" ";
            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=1;
    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:31: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:30:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
                       ^
carnival.cpp:39: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 1 ms 2024 KB Integer 12 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2024 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2024 KB Integer 2 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2024 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2024 KB Integer 3 violates the range [1, 2]
2 Halted 0 ms 0 KB -