# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
531252 | 2022-02-28T09:16:02 Z | 79brue | Newspapers (CEOI21_newspapers) | C++14 | 1 ms | 320 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m; vector<int> link[1002]; int dfs(int x, int par = -1){ vector<int> vec (1, 0); for(auto y: link[x]){ if(y==par) continue; int tmp = dfs(y, x); vec.push_back(tmp+1); } sort(vec.rbegin(), vec.rend()); if(par == -1){ if(vec.size() >= 3 && vec[2] >= 2){ puts("NO"); exit(0); } } return vec[0]; } int main(){ scanf("%d %d", &n, &m); if(m!=n-1){ puts("NO"); return 0; } for(int i=1; i<n; i++){ int x, y; scanf("%d %d", &x, &y); link[x].push_back(y), link[y].push_back(x); } for(int i=1; i<=n; i++){ dfs(i); } printf("YES"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 320 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |