Submission #519373

#TimeUsernameProblemLanguageResultExecution timeMemory
519373AmShZNewspapers (CEOI21_newspapers)C++11
4 / 100
10 ms444 KiB
//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 (2 < 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...