# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
394616 |
2021-04-27T05:55:31 Z |
Return_0 |
Network (BOI15_net) |
C++17 |
|
482 ms |
40984 KB |
// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef int ll;
typedef long double ld;
typedef pair <ll, ll> pll;
#ifdef SINA
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << std::endl; }
template <typename Arg1, typename... Args> void __f (const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); }
#define dbg2(x, j, n) cout<< #x << " : "; output((j), (n), x, 1); cout.flush();
#else
#define dbg(...) 0
#define dbg2(x, j, n) 0
#endif
#define SZ(x) ((ll)((x).size()))
#define File(s, t) freopen(s ".txt", "r", stdin); freopen(t ".txt", "w", stdout);
#define input(j, n, a) for (int _i = (j); _i < (n)+(j); _i++) cin>> a[_i];
#define output(j, n, a, t) for (int _i = (j); _i < (n)+(j); _i++) cout<< a[_i] << (((t) && _i != (n)+(j)-1)? ' ' : '\n');
#define kill(x) return cout<< (x) << endl, 0
#define cl const ll
#define fr first
#define sc second
#define lc (v << 1)
#define rc (lc | 1)
#define mid ((l + r) >> 1)
#define All(x) (x).begin(), (x).end()
cl inf = sizeof(ll) == 4 ? (1e9 + 10) : (3e18), mod = 1e9 + 7, MOD = 998244353;
template <class A,class B> ostream& operator << (ostream& out,const pair<A,B>&a){return out<<'('<<a.first<<", "<<a.second<<')';}
template <class A> ostream& operator << (ostream& out, const vector<A> &a) {
out<< '['; for (int i = -1; ++i < int(a.size());) out<< a[i] << (i + 1 < int(a.size()) ? ", " : ""); return out<<']'; }
template <class T, typename _t = less <T> > using Tree = tree <T, null_type, _t, rb_tree_tag, tree_order_statistics_node_update>;
cl N = 5e5 + 7;
ll n;
vector <ll> adj [N], vec;
void dfs (cl &v, cl &pr = 0) {
if (SZ(adj[v]) == 1) vec.push_back(v);
for (auto &u : adj[v]) if (u != pr) dfs(u, v);
}
int main ()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>> n;
for (ll i = 1, v, u; i < n; i++) {
cin>> v >> u;
adj[v].push_back(u);
adj[u].push_back(v);
}
for (ll v = 1; v <= n; v++) if (SZ(adj[v]) > 1) { dfs(v); break; }
n = (SZ(vec) + 1) / 2;
cout<< n << '\n';
n = SZ(vec) / 2;
for (ll i = 0; i + n < SZ(vec); i++) cout<< vec[i] << ' ' << vec[i + n] << '\n';
// cerr<< "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
/*
6
1 2
2 3
2 4
5 4
6 4
8
1 2
2 3
3 4
4 5
3 6
3 7
3 8
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
11980 KB |
Output is correct |
2 |
Correct |
8 ms |
12052 KB |
Output is correct |
3 |
Correct |
9 ms |
11980 KB |
Output is correct |
4 |
Correct |
8 ms |
11972 KB |
Output is correct |
5 |
Correct |
8 ms |
11980 KB |
Output is correct |
6 |
Correct |
10 ms |
11980 KB |
Output is correct |
7 |
Correct |
8 ms |
11980 KB |
Output is correct |
8 |
Correct |
9 ms |
11980 KB |
Output is correct |
9 |
Correct |
8 ms |
12048 KB |
Output is correct |
10 |
Correct |
8 ms |
11944 KB |
Output is correct |
11 |
Correct |
8 ms |
12028 KB |
Output is correct |
12 |
Correct |
8 ms |
12036 KB |
Output is correct |
13 |
Correct |
9 ms |
11980 KB |
Output is correct |
14 |
Correct |
8 ms |
11980 KB |
Output is correct |
15 |
Correct |
8 ms |
11980 KB |
Output is correct |
16 |
Correct |
8 ms |
11980 KB |
Output is correct |
17 |
Correct |
8 ms |
11980 KB |
Output is correct |
18 |
Correct |
7 ms |
11980 KB |
Output is correct |
19 |
Correct |
7 ms |
11980 KB |
Output is correct |
20 |
Correct |
7 ms |
12056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
11980 KB |
Output is correct |
2 |
Correct |
8 ms |
12052 KB |
Output is correct |
3 |
Correct |
9 ms |
11980 KB |
Output is correct |
4 |
Correct |
8 ms |
11972 KB |
Output is correct |
5 |
Correct |
8 ms |
11980 KB |
Output is correct |
6 |
Correct |
10 ms |
11980 KB |
Output is correct |
7 |
Correct |
8 ms |
11980 KB |
Output is correct |
8 |
Correct |
9 ms |
11980 KB |
Output is correct |
9 |
Correct |
8 ms |
12048 KB |
Output is correct |
10 |
Correct |
8 ms |
11944 KB |
Output is correct |
11 |
Correct |
8 ms |
12028 KB |
Output is correct |
12 |
Correct |
8 ms |
12036 KB |
Output is correct |
13 |
Correct |
9 ms |
11980 KB |
Output is correct |
14 |
Correct |
8 ms |
11980 KB |
Output is correct |
15 |
Correct |
8 ms |
11980 KB |
Output is correct |
16 |
Correct |
8 ms |
11980 KB |
Output is correct |
17 |
Correct |
8 ms |
11980 KB |
Output is correct |
18 |
Correct |
7 ms |
11980 KB |
Output is correct |
19 |
Correct |
7 ms |
11980 KB |
Output is correct |
20 |
Correct |
7 ms |
12056 KB |
Output is correct |
21 |
Correct |
18 ms |
11948 KB |
Output is correct |
22 |
Correct |
8 ms |
12108 KB |
Output is correct |
23 |
Correct |
9 ms |
12108 KB |
Output is correct |
24 |
Correct |
8 ms |
12156 KB |
Output is correct |
25 |
Correct |
8 ms |
12108 KB |
Output is correct |
26 |
Correct |
8 ms |
12108 KB |
Output is correct |
27 |
Correct |
8 ms |
12136 KB |
Output is correct |
28 |
Correct |
8 ms |
12140 KB |
Output is correct |
29 |
Correct |
9 ms |
12108 KB |
Output is correct |
30 |
Correct |
8 ms |
11952 KB |
Output is correct |
31 |
Correct |
8 ms |
12108 KB |
Output is correct |
32 |
Correct |
7 ms |
11980 KB |
Output is correct |
33 |
Correct |
7 ms |
11980 KB |
Output is correct |
34 |
Correct |
8 ms |
12052 KB |
Output is correct |
35 |
Correct |
6 ms |
11980 KB |
Output is correct |
36 |
Correct |
8 ms |
12052 KB |
Output is correct |
37 |
Correct |
9 ms |
11980 KB |
Output is correct |
38 |
Correct |
9 ms |
12080 KB |
Output is correct |
39 |
Correct |
9 ms |
12048 KB |
Output is correct |
40 |
Correct |
9 ms |
12056 KB |
Output is correct |
41 |
Correct |
8 ms |
11980 KB |
Output is correct |
42 |
Correct |
8 ms |
11980 KB |
Output is correct |
43 |
Correct |
8 ms |
11980 KB |
Output is correct |
44 |
Correct |
7 ms |
11980 KB |
Output is correct |
45 |
Correct |
7 ms |
11980 KB |
Output is correct |
46 |
Correct |
8 ms |
11980 KB |
Output is correct |
47 |
Correct |
9 ms |
11980 KB |
Output is correct |
48 |
Correct |
8 ms |
11980 KB |
Output is correct |
49 |
Correct |
10 ms |
12108 KB |
Output is correct |
50 |
Correct |
7 ms |
11980 KB |
Output is correct |
51 |
Correct |
7 ms |
11980 KB |
Output is correct |
52 |
Correct |
8 ms |
11980 KB |
Output is correct |
53 |
Correct |
7 ms |
11980 KB |
Output is correct |
54 |
Correct |
7 ms |
11980 KB |
Output is correct |
55 |
Correct |
9 ms |
11980 KB |
Output is correct |
56 |
Correct |
8 ms |
11980 KB |
Output is correct |
57 |
Correct |
9 ms |
12060 KB |
Output is correct |
58 |
Correct |
9 ms |
12108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
11980 KB |
Output is correct |
2 |
Correct |
8 ms |
12052 KB |
Output is correct |
3 |
Correct |
9 ms |
11980 KB |
Output is correct |
4 |
Correct |
8 ms |
11972 KB |
Output is correct |
5 |
Correct |
8 ms |
11980 KB |
Output is correct |
6 |
Correct |
10 ms |
11980 KB |
Output is correct |
7 |
Correct |
8 ms |
11980 KB |
Output is correct |
8 |
Correct |
9 ms |
11980 KB |
Output is correct |
9 |
Correct |
8 ms |
12048 KB |
Output is correct |
10 |
Correct |
8 ms |
11944 KB |
Output is correct |
11 |
Correct |
8 ms |
12028 KB |
Output is correct |
12 |
Correct |
8 ms |
12036 KB |
Output is correct |
13 |
Correct |
9 ms |
11980 KB |
Output is correct |
14 |
Correct |
8 ms |
11980 KB |
Output is correct |
15 |
Correct |
8 ms |
11980 KB |
Output is correct |
16 |
Correct |
8 ms |
11980 KB |
Output is correct |
17 |
Correct |
8 ms |
11980 KB |
Output is correct |
18 |
Correct |
7 ms |
11980 KB |
Output is correct |
19 |
Correct |
7 ms |
11980 KB |
Output is correct |
20 |
Correct |
7 ms |
12056 KB |
Output is correct |
21 |
Correct |
18 ms |
11948 KB |
Output is correct |
22 |
Correct |
8 ms |
12108 KB |
Output is correct |
23 |
Correct |
9 ms |
12108 KB |
Output is correct |
24 |
Correct |
8 ms |
12156 KB |
Output is correct |
25 |
Correct |
8 ms |
12108 KB |
Output is correct |
26 |
Correct |
8 ms |
12108 KB |
Output is correct |
27 |
Correct |
8 ms |
12136 KB |
Output is correct |
28 |
Correct |
8 ms |
12140 KB |
Output is correct |
29 |
Correct |
9 ms |
12108 KB |
Output is correct |
30 |
Correct |
8 ms |
11952 KB |
Output is correct |
31 |
Correct |
8 ms |
12108 KB |
Output is correct |
32 |
Correct |
7 ms |
11980 KB |
Output is correct |
33 |
Correct |
7 ms |
11980 KB |
Output is correct |
34 |
Correct |
8 ms |
12052 KB |
Output is correct |
35 |
Correct |
6 ms |
11980 KB |
Output is correct |
36 |
Correct |
8 ms |
12052 KB |
Output is correct |
37 |
Correct |
9 ms |
11980 KB |
Output is correct |
38 |
Correct |
9 ms |
12080 KB |
Output is correct |
39 |
Correct |
9 ms |
12048 KB |
Output is correct |
40 |
Correct |
9 ms |
12056 KB |
Output is correct |
41 |
Correct |
8 ms |
11980 KB |
Output is correct |
42 |
Correct |
8 ms |
11980 KB |
Output is correct |
43 |
Correct |
8 ms |
11980 KB |
Output is correct |
44 |
Correct |
7 ms |
11980 KB |
Output is correct |
45 |
Correct |
7 ms |
11980 KB |
Output is correct |
46 |
Correct |
8 ms |
11980 KB |
Output is correct |
47 |
Correct |
9 ms |
11980 KB |
Output is correct |
48 |
Correct |
8 ms |
11980 KB |
Output is correct |
49 |
Correct |
10 ms |
12108 KB |
Output is correct |
50 |
Correct |
7 ms |
11980 KB |
Output is correct |
51 |
Correct |
7 ms |
11980 KB |
Output is correct |
52 |
Correct |
8 ms |
11980 KB |
Output is correct |
53 |
Correct |
7 ms |
11980 KB |
Output is correct |
54 |
Correct |
7 ms |
11980 KB |
Output is correct |
55 |
Correct |
9 ms |
11980 KB |
Output is correct |
56 |
Correct |
8 ms |
11980 KB |
Output is correct |
57 |
Correct |
9 ms |
12060 KB |
Output is correct |
58 |
Correct |
9 ms |
12108 KB |
Output is correct |
59 |
Correct |
343 ms |
30028 KB |
Output is correct |
60 |
Correct |
428 ms |
32056 KB |
Output is correct |
61 |
Correct |
8 ms |
12048 KB |
Output is correct |
62 |
Correct |
9 ms |
11980 KB |
Output is correct |
63 |
Correct |
308 ms |
28216 KB |
Output is correct |
64 |
Correct |
27 ms |
12356 KB |
Output is correct |
65 |
Correct |
23 ms |
13644 KB |
Output is correct |
66 |
Correct |
160 ms |
25616 KB |
Output is correct |
67 |
Correct |
464 ms |
40392 KB |
Output is correct |
68 |
Correct |
482 ms |
40984 KB |
Output is correct |
69 |
Correct |
18 ms |
12748 KB |
Output is correct |
70 |
Correct |
125 ms |
19164 KB |
Output is correct |
71 |
Correct |
310 ms |
35080 KB |
Output is correct |
72 |
Correct |
331 ms |
34452 KB |
Output is correct |
73 |
Correct |
88 ms |
17356 KB |
Output is correct |
74 |
Correct |
452 ms |
31164 KB |
Output is correct |
75 |
Correct |
32 ms |
14576 KB |
Output is correct |
76 |
Correct |
313 ms |
34860 KB |
Output is correct |
77 |
Correct |
314 ms |
35104 KB |
Output is correct |
78 |
Correct |
33 ms |
14788 KB |
Output is correct |
79 |
Correct |
480 ms |
38532 KB |
Output is correct |
80 |
Correct |
10 ms |
12252 KB |
Output is correct |
81 |
Correct |
105 ms |
19212 KB |
Output is correct |
82 |
Correct |
389 ms |
33156 KB |
Output is correct |
83 |
Correct |
447 ms |
30968 KB |
Output is correct |
84 |
Correct |
459 ms |
31040 KB |
Output is correct |
85 |
Correct |
469 ms |
31016 KB |
Output is correct |
86 |
Correct |
460 ms |
32056 KB |
Output is correct |
87 |
Correct |
439 ms |
32220 KB |
Output is correct |