Submission #43394

# Submission time Handle Problem Language Result Execution time Memory
43394 2018-03-15T19:39:49 Z Hassoony Carnival (CEOI14_carnival) C++14
20 / 100
19 ms 4368 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MX=3e5+9;
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++){
        for(int j=i+1;j<=n;j++){
            if(vis[i]||vis[j])continue;
            cout<<2<<" "<<i<<" "<<j<<endl;
            int x; scanf("%d",&x);
            if(x==1)merge_(i,j),vis[j]=1;
        }
    }
    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:18:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
carnival.cpp:24:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int x; scanf("%d",&x);
                                  ^
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4368 KB Output is correct
2 Correct 7 ms 4368 KB Output is correct
3 Partially correct 17 ms 4368 KB Partially correct
4 Partially correct 18 ms 4368 KB Partially correct
5 Correct 0 ms 4368 KB Output is correct
6 Correct 0 ms 4368 KB Output is correct
7 Correct 7 ms 4368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4368 KB Output is correct
2 Correct 3 ms 4368 KB Output is correct
3 Partially correct 5 ms 4368 KB Partially correct
4 Partially correct 0 ms 4368 KB Partially correct
5 Correct 3 ms 4368 KB Output is correct
6 Correct 5 ms 4368 KB Output is correct
7 Correct 5 ms 4368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4368 KB Output is correct
2 Correct 0 ms 4368 KB Output is correct
3 Partially correct 19 ms 4368 KB Partially correct
4 Partially correct 14 ms 4368 KB Partially correct
5 Correct 13 ms 4368 KB Output is correct
6 Correct 0 ms 4368 KB Output is correct
7 Correct 1 ms 4368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4368 KB Output is correct
2 Correct 0 ms 4368 KB Output is correct
3 Partially correct 13 ms 4368 KB Partially correct
4 Partially correct 2 ms 4368 KB Partially correct
5 Correct 4 ms 4368 KB Output is correct
6 Correct 7 ms 4368 KB Output is correct
7 Correct 8 ms 4368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4368 KB Output is correct
2 Correct 3 ms 4368 KB Output is correct
3 Partially correct 7 ms 4368 KB Partially correct
4 Partially correct 4 ms 4368 KB Partially correct
5 Correct 2 ms 4368 KB Output is correct
6 Partially correct 9 ms 4368 KB Partially correct
7 Partially correct 19 ms 4368 KB Partially correct