# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
752582 |
2023-06-03T09:07:46 Z |
이동현(#9968) |
Newspapers (CEOI21_newspapers) |
C++17 |
|
4 ms |
596 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define int long long
#define mi(x, y) (x = min(x, y))
#define ma(x, y) (x = max(x, y))
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
vector<vector<int>> way(n);
cin >> n >> m;
vector<int> deg(n);
for(int i = 0; i < m; ++i){
int x, y;
cin >> x >> y;
--x, --y;
way[x].push_back(y);
way[y].push_back(x);
++deg[x], ++deg[y];
}
if(m != n - 1){
cout << "NO\n";
return 0;
}
int can = 1;
int rt = -1, mx = -1;
for(int i = 0; i < n; ++i){
if(deg[i] > mx){
mx = deg[i];
rt = i;
}
}
int cnt = 0;
for(auto&nxt:way[rt]){
cnt += (deg[nxt] > 1);
}
if(cnt > 1) can = 0;
for(int i = 0; i < n; ++i){
if(i != rt && deg[i] > 2){
can = 0;
}
}
if(can || (*max_element(deg.begin(), deg.end())) == 2){
cout << "YES\n1\n1\n";
}
else{
cout << "NO\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
4 ms |
468 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
2 ms |
596 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
4 ms |
468 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |