답안 #43397

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43397 2018-03-15T19:51:35 Z Hassoony 사육제 (CEOI14_carnival) C++14
20 / 100
22 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);
    cout<<n<<" ";
    for(int i=1;i<=n;i++){
        cout<<i<<" ";
    }
    cout<<endl;
    int x;
    scanf("%d",&x);
    if(x==n){
        cout<<0<<" ";
        for(int i=1;i<=n;i++)cout<<i<<" ";
        cout<<endl;
        return 0;
    }
    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]||find(i)==find(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:25:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&x);
                   ^
carnival.cpp:37:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int x; scanf("%d",&x);
                                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2024 KB Output is correct
2 Correct 10 ms 2024 KB Output is correct
3 Partially correct 11 ms 2024 KB Partially correct
4 Partially correct 18 ms 2024 KB Partially correct
5 Correct 4 ms 2024 KB Output is correct
6 Correct 2 ms 2024 KB Output is correct
7 Correct 1 ms 2024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2024 KB Output is correct
2 Correct 5 ms 2024 KB Output is correct
3 Partially correct 4 ms 2024 KB Partially correct
4 Partially correct 9 ms 2024 KB Partially correct
5 Correct 4 ms 2024 KB Output is correct
6 Correct 5 ms 2024 KB Output is correct
7 Correct 2 ms 2024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2024 KB Output is correct
2 Correct 4 ms 2024 KB Output is correct
3 Partially correct 3 ms 2024 KB Partially correct
4 Partially correct 13 ms 2024 KB Partially correct
5 Correct 8 ms 2024 KB Output is correct
6 Correct 6 ms 2024 KB Output is correct
7 Correct 6 ms 2024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2024 KB Output is correct
2 Correct 1 ms 2024 KB Output is correct
3 Partially correct 22 ms 2024 KB Partially correct
4 Partially correct 5 ms 2024 KB Partially correct
5 Correct 1 ms 2024 KB Output is correct
6 Correct 11 ms 2024 KB Output is correct
7 Correct 0 ms 2024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2024 KB Output is correct
2 Correct 0 ms 2024 KB Output is correct
3 Partially correct 15 ms 2024 KB Partially correct
4 Partially correct 7 ms 2024 KB Partially correct
5 Correct 6 ms 2024 KB Output is correct
6 Partially correct 16 ms 2024 KB Partially correct
7 Partially correct 14 ms 2024 KB Partially correct