# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
91863 |
2018-12-30T16:26:32 Z |
karma |
Network (BOI15_net) |
C++11 |
|
6 ms |
5112 KB |
#include<bits/stdc++.h>
#define For(i, a, b) for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName "test"
#define ll long long
#define ld long double
#define ull unsigned long
#define Print(x) cerr << #x << "is " << x << '\n';
#define pb push_back
#define X first
#define Y second
//#define Karma
using namespace std;
template<typename T> inline void Cin(T &x)
{
char c;
T sign = 1;
x = 0;
for (c = getchar(); c < '0' || c > '9'; c = getchar())
if (c == '-') sign = -1;
for (; c >= '0' && c <= '9'; c = getchar())
x = x * 10 + c - '0';
x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 2e5 + 7;
int n, u, v;
vector<int> res, a[N];
void Enter()
{
Cin(n);
For(i, 2, n)
{
Cin(u, v);
a[u].pb(v), a[v].pb(u);
}
res.pb(1);
For(i, 2, n) if(a[i].size() == 1) res.pb(i);
}
void Solve()
{
int sz = res.size();
cout << sz / 2 + (sz & 1) << '\n';
for(int i = 1; i < sz; i += 2)
cout << res[i] << ' ' << res[i - 1] << '\n';
if(sz & 1) cout << res[sz - 1] << ' ' << 1 << '\n';
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifdef Karma
freopen(FileName".inp", "r", stdin);
freopen(FileName".out", "w", stdout);
#endif // Karma
Enter();
Solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
5112 KB |
Invalid number of links. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
5112 KB |
Invalid number of links. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
5112 KB |
Invalid number of links. |
2 |
Halted |
0 ms |
0 KB |
- |