Submission #769132

# Submission time Handle Problem Language Result Execution time Memory
769132 2023-06-29T08:28:24 Z RushB Newspapers (CEOI21_newspapers) C++17
8 / 100
20 ms 596 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] = {0};
	for (auto u: adj[v]) if (u != p) {
		dfs(u, v);
		V[v].push_back(V[u][0] + 1);
	}
	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() >= 3 && 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 1 ms 368 KB Output is correct
3 Correct 1 ms 364 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 1 ms 368 KB Failed to provide a successful strategy.
7 Correct 0 ms 340 KB Output is correct
8 Runtime error 1 ms 596 KB Execution killed with signal 6
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 368 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 368 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 372 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 18 ms 468 KB Output is correct
12 Correct 6 ms 468 KB Output is correct
13 Correct 8 ms 468 KB Output is correct
14 Correct 9 ms 500 KB Output is correct
15 Correct 9 ms 468 KB Output is correct
16 Correct 19 ms 576 KB Output is correct
17 Correct 19 ms 564 KB Output is correct
18 Correct 19 ms 468 KB Output is correct
19 Correct 20 ms 460 KB Output is correct
20 Correct 20 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 368 KB Output is correct
3 Correct 1 ms 364 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 1 ms 368 KB Failed to provide a successful strategy.
7 Correct 0 ms 340 KB Output is correct
8 Runtime error 1 ms 596 KB Execution killed with signal 6
9 Halted 0 ms 0 KB -