Submission #764764

#TimeUsernameProblemLanguageResultExecution timeMemory
764764vjudge1Network (BOI15_net)C++17
0 / 100
1 ms296 KiB
#include <bits/stdc++.h> #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) #define Youarestupid ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0); #define all(x) x.begin() , x.end() #define int long long #define pb push_back #define ins insert #define sz size() #define F first #define S second const int N = 1e5 + 70 , inf = 1e18 + 77 , MOD = 1e9 + 7; const double eps = 1e-11; using namespace std; int T = 1 , sum , a[N] , t[N * 4] , q[N * 4]; int binpow(int a , int b){ if (!b) return 1; if (b % 2){ return (a * binpow(a , b - 1)) % MOD; } else{ int val = binpow(a , b / 2); return (val * val) % MOD; } } void solve(){ int n; cin >> n; vector < int > g[n + 5]; for(int i = 1; i < n; i++){ int x , y; cin >> x >> y; g[x].pb(y); g[y].pb(x); } vector < int > v; bool ok = 1; int x = 0; for(int i = 1; i <= n; i++){ if(g[i].sz == 1){ v.pb(i); if(ok){ x = i; } ok = 0; } } if(v.sz == 1){ cout << 1 << '\n'; cout << x << ' ' << (x + 1) % x; return; } if(v.sz % 2 == 1){ v.pb(x); } cout << (v.sz) / 2 << '\n'; for(int i = 0; i < v.sz - 1; i += 2){ cout << v[i] << ' ' << v[i + 1] << '\n'; } // if(v.sz % 2 == 1){ // cout << v[v.sz - 1] << ' ' << (v[v.sz - 1] + 1) % v[v.sz - 1]; // } } signed main(){ // cin >> T; while(T--){ solve(); } } /* */

Compilation message (stderr)

net.cpp: In function 'void solve()':
net.cpp:57:22: 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]
   57 |     for(int i = 0; i < v.sz - 1; i += 2){
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...