답안 #534632

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534632 2022-03-08T12:16:37 Z katwamiaw 사육제 (CEOI14_carnival) C++14
20 / 100
106 ms 576 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std ;
//fflush(stdout) ;

const int max_n=159 ;

int c[max_n] ;
vector<int>v[max_n] ;
int r=1 ;

void dfs(int x , int par , int g){
    if(c[x]!=200) return ;
    c[x]=g ;
    if(g==-1){
        c[x]=r ;
        r++ ;
    }
    for(int i:v[x]){
        if(i!=par){
            dfs(i,x,c[x]) ;
        }
    }
}

int main(){
    int n ; cin >> n ;
    for(int i=1 ; i<=n ; i++) c[i]=200 ;

    int r=1 ;
    for(int i=1 ; i<n ; i++){
        for(int j=i+1 ; j<=n ; j++){
            cout << "2 " << i << ' ' << j << '\n' ;
            fflush(stdout) ;
            int x ; cin >> x ;
            if(x==1){
                v[i].push_back(j) ;
                v[j].push_back(i) ;
            }
        }
    }
    for(int i=1 ; i<=n ; i++) dfs(i,0,-1) ;
    cout << 0 << ' ' ;
    for(int i=1 ; i<=n ; i++) cout << c[i] << ' ' ;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:30:9: warning: unused variable 'r' [-Wunused-variable]
   30 |     int r=1 ;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Partially correct 61 ms 288 KB Partially correct
2 Partially correct 86 ms 200 KB Partially correct
3 Partially correct 88 ms 200 KB Partially correct
4 Partially correct 68 ms 200 KB Partially correct
5 Partially correct 81 ms 556 KB Partially correct
6 Partially correct 77 ms 408 KB Partially correct
7 Partially correct 67 ms 280 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 83 ms 280 KB Partially correct
2 Partially correct 95 ms 284 KB Partially correct
3 Partially correct 56 ms 200 KB Partially correct
4 Partially correct 90 ms 200 KB Partially correct
5 Partially correct 75 ms 300 KB Partially correct
6 Partially correct 98 ms 448 KB Partially correct
7 Partially correct 103 ms 280 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 66 ms 320 KB Partially correct
2 Partially correct 89 ms 344 KB Partially correct
3 Partially correct 98 ms 200 KB Partially correct
4 Partially correct 83 ms 200 KB Partially correct
5 Partially correct 77 ms 300 KB Partially correct
6 Partially correct 77 ms 320 KB Partially correct
7 Partially correct 99 ms 200 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 83 ms 308 KB Partially correct
2 Partially correct 50 ms 576 KB Partially correct
3 Partially correct 106 ms 200 KB Partially correct
4 Partially correct 83 ms 200 KB Partially correct
5 Partially correct 52 ms 424 KB Partially correct
6 Partially correct 106 ms 320 KB Partially correct
7 Partially correct 99 ms 200 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 52 ms 296 KB Partially correct
2 Partially correct 89 ms 296 KB Partially correct
3 Partially correct 97 ms 276 KB Partially correct
4 Partially correct 100 ms 276 KB Partially correct
5 Partially correct 69 ms 576 KB Partially correct
6 Partially correct 103 ms 284 KB Partially correct
7 Partially correct 93 ms 200 KB Partially correct