# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
764764 |
2023-06-24T03:45:30 Z |
vjudge1 |
Network (BOI15_net) |
C++17 |
|
1 ms |
296 KB |
#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
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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
224 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Incorrect |
0 ms |
296 KB |
Breaking single line is causing network to disconnect. |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
224 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Incorrect |
0 ms |
296 KB |
Breaking single line is causing network to disconnect. |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
224 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Incorrect |
0 ms |
296 KB |
Breaking single line is causing network to disconnect. |
11 |
Halted |
0 ms |
0 KB |
- |