제출 #277494

#제출 시각아이디문제언어결과실행 시간메모리
277494FidiskNetwork (BOI15_net)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define oo 1e9 #define fi first #define se second #define sp(iiii) setprecision(iiii) #define IO ios_base::sync_with_stdio(false); cin.tie(0) #define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa)) #define cntbit(xxxx) __builtin_popcount(xxxx) #define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1) #define _cos(xxxx) cos(xxxx*acos(-1)/180) #define _sin(xxxx) sin(xxxx*acos(-1)/180) #define _tan(xxxx) tan(xxxx*acos(-1)/180) #define PE cout<<fixed typedef long double ld; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<pair<int,int>,int> piii; typedef pair<long long,long long> pll; typedef pair<pair<long long,long long>,long long> plll; const ld pi=acos(-1); int u,v,i,deg[500009],n; vector<int> ans; int main() { cin>>n; for (i=1;i<n;i++) { cin>>u>>v; deg[u]++; deg[v]++; } for (i=1;i<=n;i++) { if (deg[i]==1) { ans.push_back(i); } } cout<<(ans.size()+1)/2<<'\n'; for (i=0;i<ans.size()/2;i++) { cout<<ans[i*2]<<' '<<ans[i*2+1]<<'\n'; } if (ans.size()%2!=0) { cout<<ans[ans.size()-1]<<' '<<(ans[ans.size()-1]==1?2:1)<<'\n'; } }

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

net.cpp: In function 'int main()':
net.cpp:43:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (i=0;i<ans.size()/2;i++) {
      |              ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...