이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mxN = 405;
const int mxP = 7;
const int mod = 1e9+7;
bool vis[mxN];
int p[mxN];
vector<int> adj[mxN];
int down[mxN];
void dfs(int i)
{
for(int j : adj[i])
{
if(j == p[i]) continue;
p[j] = i;
down[j] = down[i] + 1;
dfs(j);
}
}
///dali mogu odigrati k koraka
bool solve(int i, int k)
{
if(k == 0) return true;
int cnt = 0;
for(int j : adj[i])
{
if(j == p[i]) continue;
cnt += solve(j, k-1);
}
return cnt > 1;
}
int main()
{
int n, k; cin >> n >> k;
for(int i = 1; i < n; i++)
{
int u, v; cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
dfs(1);
cout << (solve(1, k)?"NE":"DA");
}
# | 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... |