제출 #1127235

#제출 시각아이디문제언어결과실행 시간메모리
1127235KasymKNetwork (BOI15_net)C++20
100 / 100
418 ms49792 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define pli pair<ll, int> #define pll pair<ll, ll> #define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i) #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int N = 5e5+5; vector<int> adj[N], lf; void dfs(int x=1, int pr=-1){ tr(it, adj[x]) if(*it!=pr) dfs(*it, x); if((int)adj[x].size()==1) lf.pb(x); } int main(){ int n; scanf("%d", &n); for(int i = 1; i < n; ++i){ int a, b; scanf("%d%d", &a, &b); adj[a].pb(b); adj[b].pb(a); } dfs(); vector<pii> ans; for(int i = 0; i < ((int)lf.size()+1)/2; ++i) ans.pb({lf[i], lf[i+(int)lf.size()/2]}); printf("%d\n", (int)ans.size()); tr(it, ans) printf("%d %d\n", it->ff, it->ss); return 0; }

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

net.cpp: In function 'int main()':
net.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
net.cpp:31:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |                 scanf("%d%d", &a, &b);
      |                 ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...