# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
589312 |
2022-07-04T12:46:37 Z |
jasmin |
Wells (CEOI21_wells) |
C++17 |
|
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;
int dist1=0;
int dist2=0;
for(auto u: adi[v]){
if(u==p) continue;
pos=pos && dfs(u, v, k, (d+1)%k);
if(depth[u]>dist1){
dist2=dist1;
dist1=depth[u];
}
else{
dist2=max(dist2, depth[u]);
}
}
if(adi[v].size()>2 && d!=0){
if(2*(k-d)+1<=k && dist1>=(k-d) && dist2>=(k-d)){
pos=false;
}
if(min(k-d-1, dist1)+min(k-d-1, dist2)+1>=k){
pos=false;
}
}
depth[v]=dist1+1;
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 |
340 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
212 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 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
9 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
12 |
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 |
340 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
212 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 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
9 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
12 |
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 |
340 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
212 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 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
9 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
12 |
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 |
340 KB |
Output is partially correct |
3 |
Partially correct |
1 ms |
212 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 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
9 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |