Submission #769064

# Submission time Handle Problem Language Result Execution time Memory
769064 2023-06-29T06:39:07 Z RushB Newspapers (CEOI21_newspapers) C++17
8 / 100
23 ms 564 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];

void dfs(int v, int p) {
	V[v].push_back(0);
	for (auto u: adj[v]) if (u != p) {
		dfs(u, v);
		V[v].push_back(V[u][0]);
	}
	sort(V[v].rbegin(), V[v].rend());
}

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) {
		FOR(j, 0, n) V[j].clear();
		dfs(i, i);
		if (V[i].size() >= 2 && V[i][2] >= 2) {
            assert(0);
			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 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Partially correct 0 ms 340 KB Failed to provide a successful strategy.
6 Partially correct 0 ms 340 KB Failed to provide a successful strategy.
7 Correct 0 ms 340 KB Output is correct
8 Partially correct 1 ms 340 KB Failed to provide a successful strategy.
9 Incorrect 0 ms 340 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 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 16 ms 468 KB Output is correct
12 Correct 5 ms 468 KB Output is correct
13 Correct 9 ms 468 KB Output is correct
14 Correct 7 ms 476 KB Output is correct
15 Correct 8 ms 468 KB Output is correct
16 Correct 23 ms 468 KB Output is correct
17 Correct 21 ms 468 KB Output is correct
18 Correct 18 ms 468 KB Output is correct
19 Correct 17 ms 564 KB Output is correct
20 Correct 17 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Partially correct 0 ms 340 KB Failed to provide a successful strategy.
6 Partially correct 0 ms 340 KB Failed to provide a successful strategy.
7 Correct 0 ms 340 KB Output is correct
8 Partially correct 1 ms 340 KB Failed to provide a successful strategy.
9 Incorrect 0 ms 340 KB Output isn't correct
10 Halted 0 ms 0 KB -