//khodaya khodet komak kon
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
typedef pair <pii, pii> ppp;
typedef pair <ll, ll> pll;
# define A first
# define B second
# define endl '\n'
# define sep ' '
# define all(x) x.begin(), x.end()
# define kill(x) return cout << x << endl, 0
# define SZ(x) int(x.size())
# define lc id << 1
# define rc id << 1 | 1
# define fast_io ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}
const int xn = 1e3 + 10;
const int xm = - 20 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const ld eps = 1e-15;
const int mod = 998244353;
const int base = 257;
int n, m, H[xn], mx;
vector <int> adj[xn];
bool mark[xn], flag;
void DFS(int v, int p = - 1){
mark[v] = true;
mx = max(mx, H[v]);
for (int u : adj[v]){
if (mark[u]){
flag |= u != p;
continue;
}
H[u] = H[v] + 1;
DFS(u, v);
}
}
int main(){
fast_io;
cin >> n >> m;
for (int i = 1; i <= m; ++ i){
int v, u;
cin >> v >> u;
adj[v].push_back(u);
adj[u].push_back(v);
}
for (int i = 1; i <= n; ++ i){
fill(mark, mark + n + 1, false);
H[i] = 0;
DFS(i);
if (flag)
kill("NO");
}
for (int v = 1; v <= n; ++ v){
int cnt = 0;
for (int u : adj[v])
cnt += 1 < SZ(adj[u]);
if (1 < cnt && 2 < SZ(adj[v]))
kill("NO");
}
cout << "YES" << endl;
if (mx != 2)
++ mx;
cout << mx << endl;
for (int i = 1; i <= mx; ++ i)
cout << 1 << sep;
cout << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Partially correct |
0 ms |
332 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
1 ms |
340 KB |
Failed to provide a successful strategy. |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Partially correct |
0 ms |
344 KB |
Failed to provide a successful strategy. |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Partially correct |
1 ms |
332 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
1 ms |
332 KB |
Failed to provide a successful strategy. |
5 |
Partially correct |
0 ms |
204 KB |
Failed to provide a successful strategy. |
6 |
Partially correct |
1 ms |
344 KB |
Failed to provide a successful strategy. |
7 |
Partially correct |
1 ms |
332 KB |
Failed to provide a successful strategy. |
8 |
Partially correct |
0 ms |
332 KB |
Failed to provide a successful strategy. |
9 |
Partially correct |
1 ms |
336 KB |
Failed to provide a successful strategy. |
10 |
Partially correct |
0 ms |
332 KB |
Failed to provide a successful strategy. |
11 |
Partially correct |
9 ms |
452 KB |
Failed to provide a successful strategy. |
12 |
Partially correct |
5 ms |
332 KB |
Failed to provide a successful strategy. |
13 |
Partially correct |
6 ms |
332 KB |
Failed to provide a successful strategy. |
14 |
Partially correct |
4 ms |
332 KB |
Failed to provide a successful strategy. |
15 |
Partially correct |
7 ms |
332 KB |
Failed to provide a successful strategy. |
16 |
Partially correct |
9 ms |
460 KB |
Failed to provide a successful strategy. |
17 |
Partially correct |
11 ms |
332 KB |
Failed to provide a successful strategy. |
18 |
Partially correct |
9 ms |
344 KB |
Failed to provide a successful strategy. |
19 |
Partially correct |
12 ms |
456 KB |
Failed to provide a successful strategy. |
20 |
Partially correct |
12 ms |
448 KB |
Failed to provide a successful strategy. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Partially correct |
0 ms |
332 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
1 ms |
340 KB |
Failed to provide a successful strategy. |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Partially correct |
0 ms |
344 KB |
Failed to provide a successful strategy. |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |