# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1115707 | 2024-11-20T20:35:36 Z | lgmulti | Burza (COCI16_burza) | C++14 | 3 ms | 1784 KB |
#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; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1360 KB | Output is correct |
2 | Correct | 2 ms | 1616 KB | Output is correct |
3 | Incorrect | 2 ms | 1616 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1616 KB | Output is correct |
2 | Correct | 2 ms | 1616 KB | Output is correct |
3 | Incorrect | 2 ms | 1616 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1616 KB | Output is correct |
2 | Correct | 3 ms | 1616 KB | Output is correct |
3 | Incorrect | 2 ms | 1616 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1616 KB | Output is correct |
2 | Correct | 2 ms | 1616 KB | Output is correct |
3 | Incorrect | 2 ms | 1616 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1616 KB | Output is correct |
2 | Correct | 2 ms | 1488 KB | Output is correct |
3 | Incorrect | 2 ms | 1616 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1616 KB | Output is correct |
2 | Correct | 2 ms | 1616 KB | Output is correct |
3 | Incorrect | 2 ms | 1736 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1616 KB | Output is correct |
2 | Correct | 2 ms | 1568 KB | Output is correct |
3 | Incorrect | 2 ms | 1616 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1360 KB | Output is correct |
2 | Correct | 2 ms | 1484 KB | Output is correct |
3 | Incorrect | 2 ms | 1616 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1360 KB | Output is correct |
2 | Correct | 2 ms | 1616 KB | Output is correct |
3 | Incorrect | 3 ms | 1784 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1360 KB | Output is correct |
2 | Correct | 2 ms | 1616 KB | Output is correct |
3 | Incorrect | 2 ms | 1616 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |