제출 #382068

#제출 시각아이디문제언어결과실행 시간메모리
382068Aryan_RainaNetwork (BOI15_net)C++14
0 / 100
1 ms492 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define ar array const int INF = 1e17; const int MOD = 1e9 + 7; const int MXN = 5e5+9; int cnt[MXN]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; for (int i = 0; i < n-1; i++) { int a, b; cin>>a>>b; --a, --b; cnt[a]++, cnt[b]++; } vector<int> outer; for (int i = 0; i < n; i++) if (cnt[i] == 1) outer.push_back(i+1); cout<<(outer.size()+1)/2<<"\n"; for (int i = 1; i < outer.size(); i+=2) { cout<<outer[i]<<" "<<outer[i-1]<<"\n"; } if (outer.size() % 2 == 1) cout<<outer.back()<<" 1\n"; }

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

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