Submission #43404

# Submission time Handle Problem Language Result Execution time Memory
43404 2018-03-15T20:17:25 Z Hassoony Carnival (CEOI14_carnival) C++14
100 / 100
8 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_(v[ans],i);
    }
    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);
                           ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2412 KB Output is correct
2 Correct 2 ms 2412 KB Output is correct
3 Correct 1 ms 2412 KB Output is correct
4 Correct 5 ms 2412 KB Output is correct
5 Correct 1 ms 2412 KB Output is correct
6 Correct 3 ms 2412 KB Output is correct
7 Correct 1 ms 2412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2412 KB Output is correct
2 Correct 4 ms 2412 KB Output is correct
3 Correct 1 ms 2412 KB Output is correct
4 Correct 5 ms 2412 KB Output is correct
5 Correct 3 ms 2412 KB Output is correct
6 Correct 8 ms 2412 KB Output is correct
7 Correct 6 ms 2412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2412 KB Output is correct
2 Correct 7 ms 2412 KB Output is correct
3 Correct 0 ms 2412 KB Output is correct
4 Correct 0 ms 2412 KB Output is correct
5 Correct 6 ms 2412 KB Output is correct
6 Correct 3 ms 2412 KB Output is correct
7 Correct 3 ms 2412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2412 KB Output is correct
2 Correct 5 ms 2412 KB Output is correct
3 Correct 4 ms 2412 KB Output is correct
4 Correct 5 ms 2412 KB Output is correct
5 Correct 5 ms 2412 KB Output is correct
6 Correct 1 ms 2412 KB Output is correct
7 Correct 3 ms 2412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2412 KB Output is correct
2 Correct 7 ms 2412 KB Output is correct
3 Correct 0 ms 2412 KB Output is correct
4 Correct 5 ms 2412 KB Output is correct
5 Correct 6 ms 2412 KB Output is correct
6 Correct 5 ms 2412 KB Output is correct
7 Correct 3 ms 2412 KB Output is correct