# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
589556 | jasmin | Newspapers (CEOI21_newspapers) | C++14 | 66 ms | 8876 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
pair<int,int> farthest(int v, vector<vector<int> >& adi, vector<int>& p){
pair<int,int> mmax={0, v};
for(auto u: adi[v]){
if(u!=p[v]){
p[u]=v;
mmax=max(mmax, farthest(u, adi, p));
}
}
return {mmax.first+1, mmax.second};
}
vector<int> diameter(int n, vector<vector<int> >& adi){
vector<int> p(n, -1);
int root=farthest(0, adi, p).second;
p.assign(n, -1);
int v=farthest(root, adi, p).second;
vector<int> d;
d.push_back(v);
while(v!=root){
v=p[v];
d.push_back(v);
}
return d;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |