Task: | Etäisyydet |
Sender: | Anttono |
Submission time: | 2021-01-23 20:13:36 +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> using namespace std; #define N 101 int t; vector<int> v[N]; int z[N]; int c[N]; pair<int,int> f; void clearv() { for(int i=0;i<N;i++) { z[i] = c[i] = 0; v[i].resize(0); } } void deepsearch(int n, int d) { if(z[n]) return; if(d > f.second) f.second = d, f.first = n; z[n] = 1; for(auto u : v[n]) { deepsearch(u, d+1); } } void downdist(int n, int p) { c[n] = 0; for(auto u : v[n]) { if(u == p) continue; downdist(u, n); c[n] = c[u]+1 > c[n] ? c[u]+1 : c[n]; } } void updist(int n) { } int main() { cin>>t; int n; for(int i=0;i<t;i++) { clearv(); cin>>n; int a,b; for(int j=0;j<n-1;j++) { cin>>a>>b; v[a].push_back(b); v[b].push_back(a); } deepsearch(1, 0); int s = f.first; f = {0,0}; downdist(s, 0); updist(s); cout<<s<<endl; for(int j=0;j<n;j++) { cout<<c[i]<<" "; } // route(s); } }
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 |
---|
5 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 2 7 5 5 5 5 5 5 5 5 3 4 4 4 4 4 4 4 4 5 ... 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 |
---|
92 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... Truncated |