제출 #1263538

#제출 시각아이디문제언어결과실행 시간메모리
1263538dzhoz0Network (BOI15_net)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define INF 1e18 #define f first #define s second #define pii pair<int, int> #define vi vector<int> const int MOD = 1'000'000'000 + 7; void setIO(string name = "") { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #ifdef LOCAL freopen("inp.txt", "r", stdin); freopen("out.txt", "w", stdout); #else if (!name.empty()) { freopen((name + ".INP").c_str(), "r", stdin); freopen((name + ".OUT").c_str(), "w", stdout); } #endif } const int MAXN = 5e5; int n; int deg[MAXN + 5]; void solve() { cin >> n; for(int i = 1; i < n; i++) { int u, v; cin >> u >> v; deg[u]++; deg[v]++; } vi leaves; for(int i = 1; i <= n; i++) { if(deg[i] == 1) leaves.push_back(i); } if(leaves.size() % 2 == 1) leaves.push_back(leaves[0]); cout << (int)leaves.size() / 2 << '\n'; for(int i = 0; i < (int)leaves.size(); i += 2) { cout << leaves[i] << ' ' << leaves[i + 1] << '\n'; } } signed main() { setIO(); int t = 1; // cin >> t; while (t--) solve(); }

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

net.cpp: In function 'void setIO(std::string)':
net.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen((name + ".INP").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen((name + ".OUT").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...