제출 #41218

#제출 시각아이디문제언어결과실행 시간메모리
41218wzyNetwork (BOI15_net)C++14
0 / 100
10 ms12132 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define int long long // LEMBRAR DE TROCAR CASO PROBLEMA DE MEMORIA #define pii pair<int,int> #define ieps (int) 1e6 #define eps (int) 1e9 #define mp make_pair #define pb push_back int n; vector<int> adj[500005]; vector<int> ans; int32_t main(){ int n; cin>>n; int root = 0; for(int i = 0 ; i <n - 1; i++){ int x ,y; cin>>x>>y; adj[x].pb(y); adj[y].pb(x); root = x; } for(int i = 1 ; i <=n ; i++){ if(adj[i].size() == 1) ans.pb(i); } cout<< (ans.size()/2) + (ans.size()%2) << endl; for(int i = 0 ; i <( ans.size() / 2 + ans.size()%2) ; i++){ if(i == ans.size()/2 && (ans.size())%2){ cout<<ans[i] <<" " << ans[0]<<endl; continue; } cout<<ans[i] <<" " << ans[ans.size() - i - 1]<<endl; } }

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

net.cpp: In function 'int32_t main()':
net.cpp:36:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0  ; i <( ans.size() / 2 + ans.size()%2) ; i++){
                     ^
net.cpp:37:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i == ans.size()/2 && (ans.size())%2){
        ^
net.cpp:24:6: warning: variable 'root' set but not used [-Wunused-but-set-variable]
  int root = 0;
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...