제출 #233860

#제출 시각아이디문제언어결과실행 시간메모리
233860LittleFlowers__Network (BOI15_net)C++17
0 / 100
6 ms2688 KiB
#include <bits/stdc++.h> using namespace std; #define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;}) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r){return l+rng()%(r-l+1);} #define fasty ios_base::sync_with_stdio(0),cin.tie(0); #define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a) #define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a) #define forv(a,b) for(auto&a:b) #define fi first #define se second #define pb push_back #define ii pair<int,int> #define mt make_tuple #define all(a) a.begin(),a.end() #define reset(f, x) memset(f, x, sizeof(f)) #define bit(x,i) ((x>>(i-1))&1) #define on(x,i) (x|(1ll<<(i-1))) #define off(x,i) (x&~(1<<(i-1))) #define gg exit(0); const int N=100010; int n; vector<int> val; vector<int> ad[N]; void dfs(int u,int p=-1){ if(ad[u].size()<2) val.push_back(u); forv(v,ad[u]) if(v!=p) dfs(v,u); } main(){ #define task "network" //freopen(task".inp","r",stdin); //freopen(task".out","w",stdout); n=in; forinc(i,2,n){ int u=in,v=in; ad[u].pb(v); ad[v].pb(u); } int w=1; while(ad[w].size()<2) w++; dfs(w); cout<<(val.size()+1)/2<<"\n"; for(int l=0,r=val.size()-1;l<r;l++,r--) cout<<val[l]<<" "<<val[r]<<"\n"; if(val.size()&1) cout<<val[val.size()/2]<<" "<<val[0]; }

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

net.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...