제출 #727157

#제출 시각아이디문제언어결과실행 시간메모리
727157cig32Network (BOI15_net)C++17
0 / 100
1 ms324 KiB
#include "bits/stdc++.h" using namespace std; #define int long long const int MAXN = 6e5 + 10; const int MOD = 1e9 + 7; mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); int rnd(int x, int y) { int u = uniform_int_distribution<int>(x, y)(rng); return u; } int bm(int b, int p) { if(p==0) return 1 % MOD; int r = bm(b, p >> 1); if(p&1) return (((r*r) % MOD) * b) % MOD; return (r*r) % MOD; } int inv(int b) { return bm(b, MOD-2); } int fastlog(int x) { return (x == 0 ? -1 : 64 - __builtin_clzll(x) - 1); } void printcase(int i) { cout << "Case #" << i << ": "; } void solve(int tc) { int n; cin >> n; vector<int> adj[n+1]; for(int i=1; i<n; i++) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } vector<int> v; for(int i=1; i<=n; i++) if(adj[i].size() == 1) v.push_back(i); cout << (v.size() + 1) / 2 << '\n'; for(int i=0; i<v.size(); i+=2) { cout << v[i] << ' ' << v[(i+1) % (int) v.size()] << '\n'; } } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; for(int i=1; i<=t; i++) solve(i); }

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

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