제출 #32310

#제출 시각아이디문제언어결과실행 시간메모리
32310dqhungdlNetwork (BOI15_net)C++14
0 / 100
3 ms14224 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> ii; int n; bool Free[500005]; vector<int> V,g[500005]; vector<ii> rs; void DFS(int u) { Free[u]=true; if(g[u].size()==1) { V.push_back(u); return; } for(int i=0;i<g[u].size();i++) if(Free[g[u][i]]==false) DFS(g[u][i]); } int main() { cin>>n; int u,v; for(int i=1;i<n;i++) { cin>>u>>v; g[u].push_back(v); g[v].push_back(u); } for(int i=1;i<=n;i++) if(g[i].size()>=2) { DFS(i); break; } int i=0,j=V.size()-1; while(i<j) { rs.push_back(ii(V[i],V[j])); i++; j--; } if(i==j) rs.push_back(ii(V[i],V[0])); cout<<rs.size()<<"\n"; for(int i=0;i<rs.size();i++) cout<<rs[i].first<<' '<<rs[i].second<<"\n"; }

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

net.cpp: In function 'void DFS(int)':
net.cpp:18:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<g[u].size();i++)
                  ^
net.cpp: In function 'int main()':
net.cpp:49:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<rs.size();i++)
                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...