# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
589291 |
2022-07-04T11:56:45 Z |
jasmin |
Wells (CEOI21_wells) |
C++14 |
|
1 ms |
340 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct graph{
vector<vector<int> > adi;
vector<int> depth;
graph(int n){
adi.resize(n);
depth.resize(n);
}
bool dfs(int v, int p, int k, int d){
bool pos=true;
depth[v]=0;
for(auto u: adi[v]){
if(u==p) continue;
pos=pos && dfs(u, v, k, (d+1)%k);
if(d!=0 && min(depth[v], k-d-1)+min(depth[u], k-d-1)+1>=k){
pos=false;
}
depth[v]=max(depth[v], depth[u]);
}
depth[v]++;
return pos;
}
};
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
graph g(n);
for(int i=0; i<n-1; i++){
int a, b;
cin >> a >> b;
g.adi[a-1].push_back(b-1);
g.adi[b-1].push_back(a-1);
}
bool pos=false;
for(int i=0; i<n; i++){
if(g.dfs(i, -1, k, 0)){
pos=true;
}
}
if(pos){
cout << "YES\n";
}
else{
cout << "NO\n";
}
cout << 0 << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
2 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
324 KB |
Output is partially correct |
4 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
5 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
6 |
Partially correct |
1 ms |
340 KB |
Output is partially correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
2 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
324 KB |
Output is partially correct |
4 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
5 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
6 |
Partially correct |
1 ms |
340 KB |
Output is partially correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
2 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
324 KB |
Output is partially correct |
4 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
5 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
6 |
Partially correct |
1 ms |
340 KB |
Output is partially correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
2 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
324 KB |
Output is partially correct |
4 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
5 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
6 |
Partially correct |
1 ms |
340 KB |
Output is partially correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |