# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1115705 | lgmulti | Burza (COCI16_burza) | C++14 | 2 ms | 1616 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 ll long long
const ll MAXN=405;
ll n,k;
ll g[MAXN][MAXN];
vector<ll> son[MAXN];
ll father[MAXN];
void dfs(ll x){
ll i,j;
for(i=1;i<=n;i++){
if(g[x][i] && father[x]!=i){
father[i]=x;
son[x].push_back(i);
dfs(i);
}
}
}
ll maxtravtime=0;
void dfs2(ll x){
ll i,j;
maxtravtime++;
ll sonWithTheMostGrandson=0,sonWithTheSecondMostGrandson=0;
for(i=0;i<son[x].size();i++){
if(son[son[x][i]].size()>=son[sonWithTheMostGrandson].size()){
sonWithTheSecondMostGrandson=sonWithTheMostGrandson;
sonWithTheMostGrandson=son[x][i];
}
else if(son[son[x][i]].size()>=son[sonWithTheSecondMostGrandson].size())
sonWithTheSecondMostGrandson=son[x][i];
}
//cout<<x<<": "<<sonWithTheMostGrandson<<' '<<sonWithTheSecondMostGrandson<<endl;
if(sonWithTheSecondMostGrandson==0)
return;
dfs2(sonWithTheSecondMostGrandson);
}
int main(){
ll i,j;
cin>>n>>k;
for(i=1;i<n;i++){
ll u,v;
cin>>u>>v;
g[u][v]=g[v][u]=1;
}
dfs(1);
dfs2(1);
cout<<(maxtravtime<=k ? "DA" : "NE")<<endl;
return 0;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |