Submission #812587

# Submission time Handle Problem Language Result Execution time Memory
812587 2023-08-07T09:26:33 Z ono_de206 Newspapers (CEOI21_newspapers) C++14
20 / 100
262 ms 348484 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T, typename U>
ostream & operator << (ostream &out, const pair<T, U> &c) {
	out << c.first << ' ' << c.second;
    return out;
}

template<typename T>
ostream & operator << (ostream &out, vector<T> &v) {
	const int sz = v.size();
	for (int i = 0; i < sz; i++) {
		if (i) out << ' ';
		out << v[i];
	}
    return out;
}

template<typename T>
istream & operator >> (istream &in, vector<T> &v) {
	for (T &x : v) in >> x;
    return in;
}


template<typename T>
void mxx(T &a, T b){if(b > a) a = b;}
template<typename T>
void mnn(T &a, T b){if(b < a) a = b;}

const int mxn = 21, MX = 3e5 + 10;
vector<int> g[MX];
int vis[MX], k[MX], lol[1 << mxn];
pair<int, int> dp[5 * mxn][1 << mxn];

bool dfs(int to, int fr) {
	vis[to] = 1;
	for(int x : g[to]) {
		if(x == fr) continue;
		if(vis[x] || dfs(x, to)) return true;
	}
	return false;
}

void go() {
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		int x, y; cin >> x >> y; x--; y--;
		g[x].pb(y); g[y].pb(x);
		k[x] |= (1 << y); k[y] |= (1 << x);
	}

	if(dfs(0, 0)) {
		cout << "NO\n";
		return;
	}

	if(n > 20) {
		cout << "YES\n" << n * 2 - 4 << '\n';
		for(int i = 2; i < n; i++) {
			cout << i << ' ';
		}
		for(int i = n - 1; i >= 2; i--) {
			cout << i << ' ';
		}
		cout << '\n';
		return;
	}

	for(int i = 0; i < (1 << n); i++) {
		for(int j = 0; j < n; j++) {
			if((i >> j) & 1) lol[i] |= k[j];
		}
	}

	for(int i = 0; i <= 2 * n; i++) {
		for(int j = 0; j < (1 << n); j++) {
			dp[i][j] = {-1, -1};
		}
	}
	dp[0][(1 << n) - 1] = {0, 0};
	for(int i = 0; i <= 2 * n; i++) {
		if(dp[i][0].ff != -1) {
			cout << "YES\n";
			int x = i, now = 0;
			cout << x << '\n';
			vector<int> ans;
			for(int p = 0; p < x; p++) {
				ans.pb(dp[x - p][now].ss + 1);
				now = dp[x - p][now].ff;
			}
			reverse(all(ans));
			cout << ans << '\n';
			return;
		}
		if(i == 2 * n) break;
		for(int j = 0; j < (1 << n); j++) {
			if(dp[i][j].ff == -1) continue;
			for(int k = 0; k < n; k++) {
				if(!((j >> k) & 1)) continue;
				dp[i + 1][lol[j ^ (1 << k)]] = {j, k};
			}
		}
	}
	cout << "NO\n";
}
 
signed main() {
	// #ifndef ONO
	// freopen("file.in", "r", stdin);
	// freopen("file.out", "w", stdout);
	// #endif
	fast;
	int t = 1;
	// cin >> t;
	while(t--) {
		go();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 5 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 3 ms 7380 KB Output is correct
5 Correct 3 ms 7380 KB Output is correct
6 Correct 3 ms 7488 KB Output is correct
7 Correct 3 ms 7380 KB Output is correct
8 Correct 3 ms 7508 KB Output is correct
9 Correct 4 ms 7636 KB Output is correct
10 Correct 3 ms 7508 KB Output is correct
11 Correct 3 ms 7508 KB Output is correct
12 Correct 4 ms 7480 KB Output is correct
13 Correct 3 ms 7380 KB Output is correct
14 Correct 4 ms 7380 KB Output is correct
15 Correct 3 ms 7636 KB Output is correct
16 Correct 3 ms 7636 KB Output is correct
17 Correct 3 ms 7636 KB Output is correct
18 Correct 4 ms 7636 KB Output is correct
19 Correct 3 ms 7892 KB Output is correct
20 Correct 4 ms 7892 KB Output is correct
21 Correct 3 ms 7892 KB Output is correct
22 Correct 4 ms 7892 KB Output is correct
23 Correct 5 ms 8276 KB Output is correct
24 Correct 4 ms 8404 KB Output is correct
25 Correct 5 ms 8404 KB Output is correct
26 Correct 4 ms 8400 KB Output is correct
27 Correct 5 ms 9300 KB Output is correct
28 Correct 4 ms 9300 KB Output is correct
29 Correct 5 ms 9300 KB Output is correct
30 Correct 5 ms 9300 KB Output is correct
31 Correct 6 ms 11348 KB Output is correct
32 Correct 6 ms 11348 KB Output is correct
33 Correct 6 ms 11348 KB Output is correct
34 Correct 6 ms 11348 KB Output is correct
35 Correct 9 ms 15752 KB Output is correct
36 Correct 10 ms 15700 KB Output is correct
37 Correct 12 ms 15708 KB Output is correct
38 Correct 11 ms 15828 KB Output is correct
39 Correct 17 ms 24868 KB Output is correct
40 Correct 17 ms 24916 KB Output is correct
41 Correct 16 ms 24824 KB Output is correct
42 Correct 16 ms 24888 KB Output is correct
43 Correct 35 ms 44128 KB Output is correct
44 Correct 31 ms 44140 KB Output is correct
45 Correct 33 ms 44132 KB Output is correct
46 Correct 32 ms 44092 KB Output is correct
47 Correct 62 ms 84612 KB Output is correct
48 Correct 59 ms 84520 KB Output is correct
49 Correct 62 ms 84532 KB Output is correct
50 Correct 63 ms 84528 KB Output is correct
51 Correct 114 ms 169788 KB Output is correct
52 Correct 123 ms 169696 KB Output is correct
53 Correct 120 ms 169772 KB Output is correct
54 Correct 113 ms 169792 KB Output is correct
55 Correct 239 ms 348484 KB Output is correct
56 Correct 239 ms 348328 KB Output is correct
57 Correct 262 ms 348236 KB Output is correct
58 Correct 244 ms 348304 KB Output is correct
59 Correct 3 ms 7380 KB Output is correct
60 Correct 3 ms 7380 KB Output is correct
61 Correct 3 ms 7380 KB Output is correct
62 Correct 3 ms 7380 KB Output is correct
63 Correct 4 ms 7380 KB Output is correct
64 Correct 5 ms 7372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7380 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 3 ms 7380 KB Output is correct
4 Correct 3 ms 7380 KB Output is correct
5 Correct 3 ms 7380 KB Output is correct
6 Correct 4 ms 7380 KB Output is correct
7 Correct 3 ms 7508 KB Output is correct
8 Correct 3 ms 7508 KB Output is correct
9 Correct 3 ms 7508 KB Output is correct
10 Correct 3 ms 7636 KB Output is correct
11 Correct 4 ms 7380 KB Output is correct
12 Correct 3 ms 7380 KB Output is correct
13 Correct 3 ms 7380 KB Output is correct
14 Correct 3 ms 7380 KB Output is correct
15 Correct 3 ms 7380 KB Output is correct
16 Correct 3 ms 7380 KB Output is correct
17 Correct 4 ms 7380 KB Output is correct
18 Correct 4 ms 7380 KB Output is correct
19 Correct 3 ms 7380 KB Output is correct
20 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 5 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 3 ms 7380 KB Output is correct
5 Correct 3 ms 7380 KB Output is correct
6 Correct 3 ms 7488 KB Output is correct
7 Correct 3 ms 7380 KB Output is correct
8 Correct 3 ms 7508 KB Output is correct
9 Correct 4 ms 7636 KB Output is correct
10 Correct 3 ms 7508 KB Output is correct
11 Correct 3 ms 7508 KB Output is correct
12 Correct 4 ms 7480 KB Output is correct
13 Correct 3 ms 7380 KB Output is correct
14 Correct 4 ms 7380 KB Output is correct
15 Correct 3 ms 7636 KB Output is correct
16 Correct 3 ms 7636 KB Output is correct
17 Correct 3 ms 7636 KB Output is correct
18 Correct 4 ms 7636 KB Output is correct
19 Correct 3 ms 7892 KB Output is correct
20 Correct 4 ms 7892 KB Output is correct
21 Correct 3 ms 7892 KB Output is correct
22 Correct 4 ms 7892 KB Output is correct
23 Correct 5 ms 8276 KB Output is correct
24 Correct 4 ms 8404 KB Output is correct
25 Correct 5 ms 8404 KB Output is correct
26 Correct 4 ms 8400 KB Output is correct
27 Correct 5 ms 9300 KB Output is correct
28 Correct 4 ms 9300 KB Output is correct
29 Correct 5 ms 9300 KB Output is correct
30 Correct 5 ms 9300 KB Output is correct
31 Correct 6 ms 11348 KB Output is correct
32 Correct 6 ms 11348 KB Output is correct
33 Correct 6 ms 11348 KB Output is correct
34 Correct 6 ms 11348 KB Output is correct
35 Correct 9 ms 15752 KB Output is correct
36 Correct 10 ms 15700 KB Output is correct
37 Correct 12 ms 15708 KB Output is correct
38 Correct 11 ms 15828 KB Output is correct
39 Correct 17 ms 24868 KB Output is correct
40 Correct 17 ms 24916 KB Output is correct
41 Correct 16 ms 24824 KB Output is correct
42 Correct 16 ms 24888 KB Output is correct
43 Correct 35 ms 44128 KB Output is correct
44 Correct 31 ms 44140 KB Output is correct
45 Correct 33 ms 44132 KB Output is correct
46 Correct 32 ms 44092 KB Output is correct
47 Correct 62 ms 84612 KB Output is correct
48 Correct 59 ms 84520 KB Output is correct
49 Correct 62 ms 84532 KB Output is correct
50 Correct 63 ms 84528 KB Output is correct
51 Correct 114 ms 169788 KB Output is correct
52 Correct 123 ms 169696 KB Output is correct
53 Correct 120 ms 169772 KB Output is correct
54 Correct 113 ms 169792 KB Output is correct
55 Correct 239 ms 348484 KB Output is correct
56 Correct 239 ms 348328 KB Output is correct
57 Correct 262 ms 348236 KB Output is correct
58 Correct 244 ms 348304 KB Output is correct
59 Correct 3 ms 7380 KB Output is correct
60 Correct 3 ms 7380 KB Output is correct
61 Correct 3 ms 7380 KB Output is correct
62 Correct 3 ms 7380 KB Output is correct
63 Correct 4 ms 7380 KB Output is correct
64 Correct 5 ms 7372 KB Output is correct
65 Correct 4 ms 7380 KB Output is correct
66 Correct 3 ms 7380 KB Output is correct
67 Correct 4 ms 7380 KB Output is correct
68 Correct 3 ms 7380 KB Output is correct
69 Correct 3 ms 7380 KB Output is correct
70 Correct 3 ms 7508 KB Output is correct
71 Correct 3 ms 7380 KB Output is correct
72 Correct 3 ms 7380 KB Output is correct
73 Correct 3 ms 7636 KB Output is correct
74 Correct 3 ms 7508 KB Output is correct
75 Correct 3 ms 7508 KB Output is correct
76 Correct 4 ms 7524 KB Output is correct
77 Correct 3 ms 7508 KB Output is correct
78 Correct 3 ms 7380 KB Output is correct
79 Incorrect 3 ms 7380 KB Output isn't correct
80 Halted 0 ms 0 KB -