Submission #812192

# Submission time Handle Problem Language Result Execution time Memory
812192 2023-08-07T07:44:59 Z enerelt14 Newspapers (CEOI21_newspapers) C++14
15 / 100
15 ms 25216 KB
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
#define pb push_back
using namespace std;

int n, m;
vector<int> adj[1005], res[1048576];
bool vis[1048576];

vector<int> solve(int mask) {
	if(mask >= 1048576) {
		cout << "sha1";
		exit(0);
	}
	if(vis[mask]) {
		return res[mask];
	}
	vis[mask] = 1;
	if(!mask) return res[mask];
	res[mask].pb(-1);
	for(int i = 0; i < n; i++) {
		if(!(mask & (1 << i))) continue;
		int bitmask = 0;
		for(int j = 0; j < n; j++) {
			if(!(mask & (1 << j)) || i == j) continue;
			for(int k = 0; k < (int)adj[j].size(); k++) bitmask |= (1 << adj[j][k]);
		}
		vector<int> x = solve(bitmask);
		if((int)x.size() > 0 && x[0] == -1) continue;
		if(res[mask][0] == -1) {
			res[mask].pop_back();
			res[mask].pb(i + 1);
			for(int i = 0; i < (int)x.size(); i++) res[mask].pb(x[i]);
			continue;
		}
		if((int)res[mask].size() <= (int)x.size() + 1) continue;
		res[mask].clear();
		res[mask].pb(i + 1);
		for(int i = 0; i < (int)x.size(); i++) res[mask].pb(x[i]);
	}
	return res[mask];
}

void go() {
	vector<int> ans = solve((1 << n) - 1);
	if(ans[0] == -1) {
		cout << "NO\n";
		return;
	}
	cout << "YES\n";
	cout << (int)ans.size() << "\n";
	for(int i = 0; i < (int)ans.size(); i++) {
		cout << ans[i] << " ";
	}
}

int main() {
	cin >> n >> m;
	if(m >= n) {
		cout << "NO\n";
		return 0;
	}
	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	if(n <= 20) {
		go();
		return 0;
	}
	cout << "YES\n";
	cout << 2 * (n - 2) << "\n";
	for(int i = 2; i < n; i++) {
		cout << i << " ";
	}
	for(int i = n - 1; i > 1; i--) {
		cout << i << " ";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 24916 KB Output is correct
2 Correct 12 ms 24868 KB Output is correct
3 Correct 12 ms 24916 KB Output is correct
4 Correct 12 ms 24916 KB Output is correct
5 Correct 12 ms 24952 KB Output is correct
6 Correct 12 ms 24916 KB Output is correct
7 Correct 12 ms 24956 KB Output is correct
8 Correct 13 ms 24928 KB Output is correct
9 Correct 13 ms 24916 KB Output is correct
10 Correct 13 ms 24936 KB Output is correct
11 Correct 12 ms 24916 KB Output is correct
12 Correct 13 ms 24836 KB Output is correct
13 Correct 14 ms 25060 KB Output is correct
14 Correct 11 ms 24916 KB Output is correct
15 Correct 12 ms 24916 KB Output is correct
16 Correct 12 ms 24952 KB Output is correct
17 Correct 12 ms 24956 KB Output is correct
18 Correct 12 ms 24876 KB Output is correct
19 Correct 11 ms 24960 KB Output is correct
20 Correct 14 ms 24960 KB Output is correct
21 Correct 12 ms 24956 KB Output is correct
22 Correct 12 ms 24916 KB Output is correct
23 Correct 12 ms 24952 KB Output is correct
24 Correct 13 ms 24904 KB Output is correct
25 Correct 12 ms 24868 KB Output is correct
26 Correct 12 ms 24952 KB Output is correct
27 Correct 13 ms 24892 KB Output is correct
28 Correct 13 ms 24932 KB Output is correct
29 Correct 12 ms 24916 KB Output is correct
30 Correct 13 ms 24980 KB Output is correct
31 Correct 12 ms 24952 KB Output is correct
32 Correct 13 ms 24940 KB Output is correct
33 Correct 12 ms 24952 KB Output is correct
34 Correct 13 ms 24944 KB Output is correct
35 Correct 12 ms 24916 KB Output is correct
36 Correct 13 ms 24940 KB Output is correct
37 Correct 13 ms 24952 KB Output is correct
38 Correct 12 ms 24956 KB Output is correct
39 Correct 12 ms 24980 KB Output is correct
40 Correct 12 ms 24916 KB Output is correct
41 Correct 12 ms 24968 KB Output is correct
42 Correct 12 ms 24916 KB Output is correct
43 Correct 12 ms 25088 KB Output is correct
44 Partially correct 12 ms 25044 KB Provide a successful but not optimal strategy.
45 Correct 13 ms 24916 KB Output is correct
46 Correct 13 ms 24956 KB Output is correct
47 Correct 13 ms 25044 KB Output is correct
48 Correct 13 ms 25172 KB Output is correct
49 Correct 13 ms 24976 KB Output is correct
50 Correct 13 ms 25060 KB Output is correct
51 Correct 13 ms 25172 KB Output is correct
52 Correct 12 ms 24916 KB Output is correct
53 Correct 15 ms 25012 KB Output is correct
54 Correct 13 ms 25100 KB Output is correct
55 Correct 13 ms 25080 KB Output is correct
56 Correct 13 ms 24948 KB Output is correct
57 Correct 14 ms 25216 KB Output is correct
58 Correct 13 ms 24984 KB Output is correct
59 Correct 13 ms 24952 KB Output is correct
60 Correct 13 ms 24916 KB Output is correct
61 Correct 14 ms 24956 KB Output is correct
62 Correct 12 ms 24956 KB Output is correct
63 Correct 12 ms 24916 KB Output is correct
64 Correct 13 ms 24916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 24872 KB Output is correct
2 Correct 12 ms 24864 KB Output is correct
3 Correct 12 ms 24888 KB Output is correct
4 Correct 12 ms 24904 KB Output is correct
5 Correct 12 ms 24912 KB Output is correct
6 Correct 13 ms 24908 KB Output is correct
7 Correct 12 ms 24916 KB Output is correct
8 Correct 12 ms 24916 KB Output is correct
9 Correct 12 ms 24916 KB Output is correct
10 Partially correct 13 ms 24900 KB Provide a successful but not optimal strategy.
11 Correct 13 ms 24984 KB Output is correct
12 Correct 12 ms 24956 KB Output is correct
13 Correct 13 ms 24980 KB Output is correct
14 Correct 12 ms 24916 KB Output is correct
15 Correct 13 ms 24924 KB Output is correct
16 Correct 12 ms 24996 KB Output is correct
17 Correct 12 ms 24916 KB Output is correct
18 Correct 12 ms 24932 KB Output is correct
19 Correct 13 ms 24912 KB Output is correct
20 Correct 12 ms 24916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 24916 KB Output is correct
2 Correct 12 ms 24868 KB Output is correct
3 Correct 12 ms 24916 KB Output is correct
4 Correct 12 ms 24916 KB Output is correct
5 Correct 12 ms 24952 KB Output is correct
6 Correct 12 ms 24916 KB Output is correct
7 Correct 12 ms 24956 KB Output is correct
8 Correct 13 ms 24928 KB Output is correct
9 Correct 13 ms 24916 KB Output is correct
10 Correct 13 ms 24936 KB Output is correct
11 Correct 12 ms 24916 KB Output is correct
12 Correct 13 ms 24836 KB Output is correct
13 Correct 14 ms 25060 KB Output is correct
14 Correct 11 ms 24916 KB Output is correct
15 Correct 12 ms 24916 KB Output is correct
16 Correct 12 ms 24952 KB Output is correct
17 Correct 12 ms 24956 KB Output is correct
18 Correct 12 ms 24876 KB Output is correct
19 Correct 11 ms 24960 KB Output is correct
20 Correct 14 ms 24960 KB Output is correct
21 Correct 12 ms 24956 KB Output is correct
22 Correct 12 ms 24916 KB Output is correct
23 Correct 12 ms 24952 KB Output is correct
24 Correct 13 ms 24904 KB Output is correct
25 Correct 12 ms 24868 KB Output is correct
26 Correct 12 ms 24952 KB Output is correct
27 Correct 13 ms 24892 KB Output is correct
28 Correct 13 ms 24932 KB Output is correct
29 Correct 12 ms 24916 KB Output is correct
30 Correct 13 ms 24980 KB Output is correct
31 Correct 12 ms 24952 KB Output is correct
32 Correct 13 ms 24940 KB Output is correct
33 Correct 12 ms 24952 KB Output is correct
34 Correct 13 ms 24944 KB Output is correct
35 Correct 12 ms 24916 KB Output is correct
36 Correct 13 ms 24940 KB Output is correct
37 Correct 13 ms 24952 KB Output is correct
38 Correct 12 ms 24956 KB Output is correct
39 Correct 12 ms 24980 KB Output is correct
40 Correct 12 ms 24916 KB Output is correct
41 Correct 12 ms 24968 KB Output is correct
42 Correct 12 ms 24916 KB Output is correct
43 Correct 12 ms 25088 KB Output is correct
44 Partially correct 12 ms 25044 KB Provide a successful but not optimal strategy.
45 Correct 13 ms 24916 KB Output is correct
46 Correct 13 ms 24956 KB Output is correct
47 Correct 13 ms 25044 KB Output is correct
48 Correct 13 ms 25172 KB Output is correct
49 Correct 13 ms 24976 KB Output is correct
50 Correct 13 ms 25060 KB Output is correct
51 Correct 13 ms 25172 KB Output is correct
52 Correct 12 ms 24916 KB Output is correct
53 Correct 15 ms 25012 KB Output is correct
54 Correct 13 ms 25100 KB Output is correct
55 Correct 13 ms 25080 KB Output is correct
56 Correct 13 ms 24948 KB Output is correct
57 Correct 14 ms 25216 KB Output is correct
58 Correct 13 ms 24984 KB Output is correct
59 Correct 13 ms 24952 KB Output is correct
60 Correct 13 ms 24916 KB Output is correct
61 Correct 14 ms 24956 KB Output is correct
62 Correct 12 ms 24956 KB Output is correct
63 Correct 12 ms 24916 KB Output is correct
64 Correct 13 ms 24916 KB Output is correct
65 Correct 11 ms 24916 KB Output is correct
66 Correct 12 ms 24864 KB Output is correct
67 Correct 11 ms 24952 KB Output is correct
68 Correct 11 ms 24916 KB Output is correct
69 Correct 11 ms 24916 KB Output is correct
70 Correct 11 ms 24852 KB Output is correct
71 Correct 11 ms 24928 KB Output is correct
72 Correct 11 ms 24916 KB Output is correct
73 Correct 11 ms 24960 KB Output is correct
74 Correct 10 ms 24952 KB Output is correct
75 Correct 11 ms 24952 KB Output is correct
76 Correct 12 ms 24956 KB Output is correct
77 Correct 11 ms 24916 KB Output is correct
78 Correct 11 ms 24868 KB Output is correct
79 Incorrect 11 ms 24956 KB Output isn't correct
80 Halted 0 ms 0 KB -