#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
vector<int> path[100];
vector<int> adj[100];
void dfs(int x, int p, int r) {
for (auto &y : adj[x]) {
if (y == p) continue;
path[r].push_back(y);
dfs(y, x, r);
path[r].push_back(x);
}
}
int main() {
ios_base :: sync_with_stdio(false); cin.tie(NULL);
int N;
cin >> N;
if (N != 100) {
//return 0;
}
for (int i=0; i<N-1; i++) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int i=0; i<N; i++) {
dfs(i, -1, i);
}
cout << (2*N-2) * 2 << '\n';
for (int i=0; i<N; i++) {
for (int j=0; j<2*N-2; j++) {
cout << path[i][j] << ' ' << path[i][j];
if (j == 2*N-3) cout << '\n';
else cout << ' ';
}
}
for (int i=0; i<N; i++) {
for (int j=0; j<(2*N-2) * 2; j++) {
cout << i;
if (j == (2*N-2) * 2-1) cout << '\n';
else cout << ' ';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
3 ms |
600 KB |
Partially correct |
2 |
Partially correct |
4 ms |
604 KB |
Partially correct |
3 |
Partially correct |
4 ms |
600 KB |
Partially correct |
4 |
Partially correct |
3 ms |
604 KB |
Partially correct |
5 |
Partially correct |
3 ms |
604 KB |
Partially correct |
6 |
Partially correct |
3 ms |
604 KB |
Partially correct |
7 |
Partially correct |
4 ms |
712 KB |
Partially correct |
8 |
Partially correct |
3 ms |
756 KB |
Partially correct |
9 |
Partially correct |
4 ms |
604 KB |
Partially correct |
10 |
Partially correct |
4 ms |
604 KB |
Partially correct |
11 |
Partially correct |
3 ms |
604 KB |
Partially correct |
12 |
Partially correct |
3 ms |
568 KB |
Partially correct |
13 |
Partially correct |
3 ms |
604 KB |
Partially correct |
14 |
Partially correct |
3 ms |
604 KB |
Partially correct |
15 |
Partially correct |
3 ms |
792 KB |
Partially correct |
16 |
Partially correct |
7 ms |
604 KB |
Partially correct |
17 |
Partially correct |
4 ms |
604 KB |
Partially correct |
18 |
Partially correct |
3 ms |
604 KB |
Partially correct |
19 |
Partially correct |
3 ms |
600 KB |
Partially correct |
20 |
Partially correct |
3 ms |
636 KB |
Partially correct |
21 |
Partially correct |
3 ms |
604 KB |
Partially correct |
22 |
Partially correct |
3 ms |
604 KB |
Partially correct |
23 |
Partially correct |
3 ms |
604 KB |
Partially correct |
24 |
Partially correct |
3 ms |
600 KB |
Partially correct |
25 |
Partially correct |
3 ms |
604 KB |
Partially correct |