제출 #443472

#제출 시각아이디문제언어결과실행 시간메모리
443472BeanZNetwork (BOI15_net)C++14
0 / 100
17 ms23756 KiB
// I_Love_LPL 1y0m2d #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 1e6 + 5; long long mod = 1000007; const int lim = 4e5 + 5; const int lg = 20; const int base = 311; const long double eps = 1e-6; vector<ll> node[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("tests.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll n; cin >> n; for (int i = 1; i < n; i++){ ll u, v; cin >> u >> v; node[u].push_back(v); node[v].push_back(u); } vector<ll> one; vector<pair<ll, ll>> ans; for (int i = 1; i <= n; i++){ if (node[i].size() == 1){ one.push_back(i); } } random_shuffle(one.begin(), one.end()); for (int i = 1; i < one.size(); i += 2){ ans.push_back({one[i], one[i - 1]}); } if (one.size() & 1) ans.push_back({one[0], one[one.size() - 1]}); cout << ans.size() << endl; for (auto j : ans){ cout << j.first << " " << j.second << endl; } } /* Ans: Out: */

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

net.cpp: In function 'int main()':
net.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i = 1; i < one.size(); i += 2){
      |                     ~~^~~~~~~~~~~~
net.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
net.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...