Submission #769161

# Submission time Handle Problem Language Result Execution time Memory
769161 2023-06-29T09:06:08 Z RushB Newspapers (CEOI21_newspapers) C++17
8 / 100
1 ms 468 KB
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
using namespace std;
const long long INF = 1ll << 60;
const int N = 1000 + 5;
vector<int> adj[N], V[N];

signed main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int n, m;
	cin >> n >> m;
	if (m >= n) {
		cout << "NO\n";
		return 0;
	}
	if (n <= 2) {
		cout << "YES\n";
		cout << n << '\n';
		FOR(i, 0, n) cout << 1 << ' ';
		return 0;
	}
	FOR(i, 1, n) {
		int u, v; cin >> u >> v;	
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	FOR(i, 0, n) {
		int ch = 0;
		for (auto u: adj[i]) 
			ch += (adj[u].size() > 1);
		if (ch >= 3) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	cout << 2 * n - 4 << '\n';
	FOR(i, 1, n - 1) cout << i + 1 << ' ';
	FOR(i, 1, n - 1) cout << n - i << ' ';
	cout << '\n';
	return 0;
}
//Reading this fills you with DETERMINATION
//20:06:46
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Partially correct 1 ms 340 KB Failed to provide a successful strategy.
6 Partially correct 1 ms 368 KB Failed to provide a successful strategy.
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 0 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 368 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 376 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 372 KB Output is correct
19 Correct 1 ms 392 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Partially correct 1 ms 340 KB Failed to provide a successful strategy.
6 Partially correct 1 ms 368 KB Failed to provide a successful strategy.
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 0 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -