#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 - 1 << '\n';
for (int i=0; i<N; i++) {
for (int j=0; j<2*N-2; j++) {
if (j != 0) cout << i << ' ';
cout << path[i][j];
if (j == 2*N-3) cout << '\n';
else cout << ' ';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
604 KB |
Cannot move |
2 |
Halted |
0 ms |
0 KB |
- |