# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1115707 | lgmulti | Burza (COCI16_burza) | C++14 | 3 ms | 1784 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 ? "NE" : "DA")<<endl;
return 0;
}
컴파일 시 표준 에러 (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... |