| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 361923 | ogibogi2004 | Cat in a tree (BOI17_catinatree) | C++14 | 4 ms | 4972 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+6;
int cnt,d;
vector<int>g[MAXN];
void dfs(int u,int par,int depth)
{
if(depth%d==0)cnt++;
for(auto v:g[u])
{
if(v==par)continue;
dfs(v,u,depth+1);
}
}
int n;
int main()
{
cin>>n>>d;
for(int i=1;i<n;i++)
{
int x;
cin>>x;
g[x].push_back(i);
g[i].push_back(x);
}
int ans=0;
for(int i=0;i<n;i++)
{
cnt=0;
dfs(i,-1,0);
ans=max(ans,cnt);
}
cout<<ans<<endl;
return 0;
}
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
