답안 #519369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
519369 2022-01-26T09:16:05 Z AmShZ Newspapers (CEOI21_newspapers) C++11
0 / 100
1 ms 344 KB
//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)
			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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Incorrect 0 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Partially correct 1 ms 332 KB Failed to provide a successful strategy.
4 Partially correct 0 ms 332 KB Failed to provide a successful strategy.
5 Incorrect 1 ms 332 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Incorrect 0 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -