제출 #475741

#제출 시각아이디문제언어결과실행 시간메모리
475741soba사육제 (CEOI14_carnival)C++14
100 / 100
47 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int par[151], siz[151]; int fnd(int node) { if(par[node]!=node) { return par[node]=fnd(par[node]); } return par[node]=node; } void uni(int a, int b) { a=fnd(a); b=fnd(b); if(a==b) return; if(siz[a]>siz[b]) { par[b]=a; siz[a]++; } else { par[a]=b; siz[b]++; } return ; } int main() { int n; cin >> n; int start=1 , nxt , q; for(int i =1 ; i<= n ;i++) { siz[i]=1; par[i]=i; } int head[151] , had, expected=2 , hh; for(int i =2 ; i<= n ; i++) { //cout << expected << "\n"; cout << i << " "; for(int j =1 ; j<= i ; j++) { cout << j << " "; } cout << "\n"; cout.flush(); cin >> had; if(had==expected) { head[i]++; expected++; //cout << "here\n"; continue; } hh=1; for(int j = 2 ; j< i ; j++) { if(!head[j])continue; cout << 2 << " " << i << " " << j << "\n"; cout.flush(); cin >> q ; if(q==1) { uni(i , j); hh=j; break; } } if(hh==1) { uni(i,1); } expected=had+1; } int cnt=1; map<int,int>mp; for(int i =1 ; i<=n ; i++) { q=fnd(i); if(mp[q]==0)mp[q]=cnt++; } cout << 0 << " "; for(int i =1 ; i<=n ; i++) { q=fnd(i); cout <<mp[q] << " "; } cout <<"\n"; cout.flush(); }

컴파일 시 표준 에러 (stderr) 메시지

carnival.cpp: In function 'int main()':
carnival.cpp:36:9: warning: unused variable 'start' [-Wunused-variable]
   36 |     int start=1 , nxt , q;
      |         ^~~~~
carnival.cpp:36:19: warning: unused variable 'nxt' [-Wunused-variable]
   36 |     int start=1 , nxt , q;
      |                   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...