Task: | Distances |
Sender: | andr1y |
Submission time: | 2021-01-30 14:59:06 +0200 |
Language: | C++ (C++17) |
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 |
Compiler report
input/code.cpp: In function 'bool check(ll)': input/code.cpp:33:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation] for(auto i : res) cout<<i<<' ';cout<<'\n'; ^~~ input/code.cpp:33:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for' for(auto i : res) cout<<i<<' ';cout<<'\n'; ^~~~
Code
// -- // #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll N = 120; vector<ll> d[N]; bool dnu[N]; ll lval, lvert, n; void dfs(ll v, ll p=-1, ll len=0){ if(!dnu[v]&&len>lval) lval=len, lvert=v; if(len==3) return; for(auto i : d[v]){ if(i!=p) dfs(i, v, len+1); } } bool check(ll v){ vector<ll> res; res.push_back(v); dnu[v]=1; for(ll i = 1;i<n;i++){ lval=0, lvert=v; dfs(v); ll e = lvert; res.push_back(e); if(dnu[e]){ v=-1; break; } dnu[e]=1; v=e; } if(v==-1) return false; for(auto i : res) cout<<i<<' ';cout<<'\n'; return true; } signed main(){ cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); ll q; cin >> q; while(q--){ cin >> n; for(ll i = 1;i<=n;i++) d[i].clear(), dnu[i]=0; for(ll a, b, i=1;i<n;i++){ cin >> a >> b; d[a].push_back(b); d[b].push_back(a); } for(ll i = 1;i<=n;i++){ if(check(i))break; } } }
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 3 5 7 6 8 2 4 1 8 3 2 7 5 6 4 1 3 2 5 8 4 7 6 1 3 5 7 8 6 4 2 1 4 2 3 7 5 8 6 ... 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 |
---|
(empty) |