| Task: | Etäisyydet |
| Sender: | Mahtimursu |
| Submission time: | 2021-01-31 11:42:22 +0200 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.01 s | 1, 2 | details |
| #2 | WRONG ANSWER | 0.01 s | 2 | details |
Code
#include <bits/stdc++.h>
typedef long long ll;
#define M 1000000007
#define N (1 << 18)
using namespace std;
vector<int> v[101];
vector<int> ans;
void dfs(int s, int e, bool put) {
if (put) {
ans.push_back(s);
}
bool nxt = put ^ 1;
for (int u : v[s]) {
if (u == e) continue;
dfs(u, s, nxt);
nxt ^= 1;
}
if (!put) {
ans.push_back(s);
}
}
void test_case() {
int n;
cin >> n;
for (int i = 1; i <= n; ++i) {
v[i].clear();
}
ans.clear();
for (int i = 1; i < n; ++i) {
int a, b;
cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
}
dfs(1, -1, 1);
for (int x : ans) cout << x << " ";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 0;
cin >> t;
for (int i = 0; i < t; ++i) {
test_case();
cout << "\n";
}
return 0;
}Test details
Test 1
Group: 1, 2
Verdict: WRONG ANSWER
| input |
|---|
| 100 8 5 2 2 3 3 7 ... |
| correct output |
|---|
| 1 8 2 5 6 7 3 4 1 7 2 8 3 6 4 5 1 4 6 2 7 5 8 3 1 8 3 2 4 7 6 5 1 6 4 7 5 2 3 8 ... |
| user output |
|---|
| 1 8 2 5 6 7 3 4 1 7 2 8 3 5 6 4 1 4 3 8 7 2 5 6 1 8 3 2 4 7 6 5 1 6 8 3 2 5 7 4 ... Truncated |
Test 2
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 100 100 37 59 81 37 44 81 ... |
| correct output |
|---|
| 1 99 82 81 59 5 71 55 17 24 13... |
| user output |
|---|
| 1 99 82 81 59 5 55 71 17 24 13... Truncated |
