#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 |
3 ms |
7380 KB |
Output is correct |
2 |
Correct |
4 ms |
7372 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 |
5 ms |
7508 KB |
Output is correct |
7 |
Correct |
6 ms |
7380 KB |
Output is correct |
8 |
Correct |
5 ms |
7504 KB |
Output is correct |
9 |
Correct |
3 ms |
7636 KB |
Output is correct |
10 |
Correct |
4 ms |
7500 KB |
Output is correct |
11 |
Correct |
3 ms |
7508 KB |
Output is correct |
12 |
Correct |
4 ms |
7500 KB |
Output is correct |
13 |
Correct |
4 ms |
7424 KB |
Output is correct |
14 |
Correct |
4 ms |
7380 KB |
Output is correct |
15 |
Correct |
4 ms |
7636 KB |
Output is correct |
16 |
Correct |
3 ms |
7636 KB |
Output is correct |
17 |
Correct |
5 ms |
7656 KB |
Output is correct |
18 |
Correct |
3 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 |
6 ms |
8400 KB |
Output is correct |
24 |
Correct |
4 ms |
8396 KB |
Output is correct |
25 |
Correct |
4 ms |
8404 KB |
Output is correct |
26 |
Correct |
4 ms |
8400 KB |
Output is correct |
27 |
Correct |
7 ms |
9300 KB |
Output is correct |
28 |
Correct |
5 ms |
9300 KB |
Output is correct |
29 |
Correct |
6 ms |
9248 KB |
Output is correct |
30 |
Correct |
6 ms |
9300 KB |
Output is correct |
31 |
Correct |
8 ms |
11340 KB |
Output is correct |
32 |
Correct |
8 ms |
11348 KB |
Output is correct |
33 |
Correct |
7 ms |
11340 KB |
Output is correct |
34 |
Correct |
9 ms |
11348 KB |
Output is correct |
35 |
Correct |
9 ms |
15700 KB |
Output is correct |
36 |
Correct |
9 ms |
15760 KB |
Output is correct |
37 |
Correct |
9 ms |
15828 KB |
Output is correct |
38 |
Correct |
10 ms |
15700 KB |
Output is correct |
39 |
Correct |
20 ms |
24924 KB |
Output is correct |
40 |
Correct |
15 ms |
24916 KB |
Output is correct |
41 |
Correct |
17 ms |
24832 KB |
Output is correct |
42 |
Correct |
18 ms |
24936 KB |
Output is correct |
43 |
Correct |
38 ms |
44148 KB |
Output is correct |
44 |
Correct |
31 ms |
44108 KB |
Output is correct |
45 |
Correct |
33 ms |
44088 KB |
Output is correct |
46 |
Correct |
29 ms |
44044 KB |
Output is correct |
47 |
Correct |
57 ms |
84528 KB |
Output is correct |
48 |
Correct |
53 ms |
84540 KB |
Output is correct |
49 |
Correct |
58 ms |
84600 KB |
Output is correct |
50 |
Correct |
64 ms |
84504 KB |
Output is correct |
51 |
Correct |
112 ms |
169772 KB |
Output is correct |
52 |
Correct |
117 ms |
169724 KB |
Output is correct |
53 |
Correct |
110 ms |
169696 KB |
Output is correct |
54 |
Correct |
102 ms |
169736 KB |
Output is correct |
55 |
Correct |
248 ms |
348228 KB |
Output is correct |
56 |
Correct |
250 ms |
348332 KB |
Output is correct |
57 |
Correct |
239 ms |
348264 KB |
Output is correct |
58 |
Correct |
270 ms |
348292 KB |
Output is correct |
59 |
Correct |
3 ms |
7380 KB |
Output is correct |
60 |
Correct |
4 ms |
7380 KB |
Output is correct |
61 |
Correct |
3 ms |
7372 KB |
Output is correct |
62 |
Correct |
3 ms |
7380 KB |
Output is correct |
63 |
Correct |
5 ms |
7380 KB |
Output is correct |
64 |
Correct |
5 ms |
7380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7376 KB |
Output is correct |
2 |
Correct |
4 ms |
7380 KB |
Output is correct |
3 |
Correct |
4 ms |
7380 KB |
Output is correct |
4 |
Correct |
4 ms |
7372 KB |
Output is correct |
5 |
Correct |
4 ms |
7380 KB |
Output is correct |
6 |
Correct |
4 ms |
7380 KB |
Output is correct |
7 |
Correct |
4 ms |
7508 KB |
Output is correct |
8 |
Correct |
4 ms |
7508 KB |
Output is correct |
9 |
Correct |
4 ms |
7508 KB |
Output is correct |
10 |
Correct |
4 ms |
7636 KB |
Output is correct |
11 |
Correct |
6 ms |
7380 KB |
Output is correct |
12 |
Correct |
5 ms |
7380 KB |
Output is correct |
13 |
Correct |
4 ms |
7380 KB |
Output is correct |
14 |
Correct |
5 ms |
7380 KB |
Output is correct |
15 |
Correct |
4 ms |
7384 KB |
Output is correct |
16 |
Correct |
5 ms |
7380 KB |
Output is correct |
17 |
Correct |
5 ms |
7376 KB |
Output is correct |
18 |
Correct |
6 ms |
7380 KB |
Output is correct |
19 |
Correct |
4 ms |
7380 KB |
Output is correct |
20 |
Correct |
4 ms |
7380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7380 KB |
Output is correct |
2 |
Correct |
4 ms |
7372 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 |
5 ms |
7508 KB |
Output is correct |
7 |
Correct |
6 ms |
7380 KB |
Output is correct |
8 |
Correct |
5 ms |
7504 KB |
Output is correct |
9 |
Correct |
3 ms |
7636 KB |
Output is correct |
10 |
Correct |
4 ms |
7500 KB |
Output is correct |
11 |
Correct |
3 ms |
7508 KB |
Output is correct |
12 |
Correct |
4 ms |
7500 KB |
Output is correct |
13 |
Correct |
4 ms |
7424 KB |
Output is correct |
14 |
Correct |
4 ms |
7380 KB |
Output is correct |
15 |
Correct |
4 ms |
7636 KB |
Output is correct |
16 |
Correct |
3 ms |
7636 KB |
Output is correct |
17 |
Correct |
5 ms |
7656 KB |
Output is correct |
18 |
Correct |
3 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 |
6 ms |
8400 KB |
Output is correct |
24 |
Correct |
4 ms |
8396 KB |
Output is correct |
25 |
Correct |
4 ms |
8404 KB |
Output is correct |
26 |
Correct |
4 ms |
8400 KB |
Output is correct |
27 |
Correct |
7 ms |
9300 KB |
Output is correct |
28 |
Correct |
5 ms |
9300 KB |
Output is correct |
29 |
Correct |
6 ms |
9248 KB |
Output is correct |
30 |
Correct |
6 ms |
9300 KB |
Output is correct |
31 |
Correct |
8 ms |
11340 KB |
Output is correct |
32 |
Correct |
8 ms |
11348 KB |
Output is correct |
33 |
Correct |
7 ms |
11340 KB |
Output is correct |
34 |
Correct |
9 ms |
11348 KB |
Output is correct |
35 |
Correct |
9 ms |
15700 KB |
Output is correct |
36 |
Correct |
9 ms |
15760 KB |
Output is correct |
37 |
Correct |
9 ms |
15828 KB |
Output is correct |
38 |
Correct |
10 ms |
15700 KB |
Output is correct |
39 |
Correct |
20 ms |
24924 KB |
Output is correct |
40 |
Correct |
15 ms |
24916 KB |
Output is correct |
41 |
Correct |
17 ms |
24832 KB |
Output is correct |
42 |
Correct |
18 ms |
24936 KB |
Output is correct |
43 |
Correct |
38 ms |
44148 KB |
Output is correct |
44 |
Correct |
31 ms |
44108 KB |
Output is correct |
45 |
Correct |
33 ms |
44088 KB |
Output is correct |
46 |
Correct |
29 ms |
44044 KB |
Output is correct |
47 |
Correct |
57 ms |
84528 KB |
Output is correct |
48 |
Correct |
53 ms |
84540 KB |
Output is correct |
49 |
Correct |
58 ms |
84600 KB |
Output is correct |
50 |
Correct |
64 ms |
84504 KB |
Output is correct |
51 |
Correct |
112 ms |
169772 KB |
Output is correct |
52 |
Correct |
117 ms |
169724 KB |
Output is correct |
53 |
Correct |
110 ms |
169696 KB |
Output is correct |
54 |
Correct |
102 ms |
169736 KB |
Output is correct |
55 |
Correct |
248 ms |
348228 KB |
Output is correct |
56 |
Correct |
250 ms |
348332 KB |
Output is correct |
57 |
Correct |
239 ms |
348264 KB |
Output is correct |
58 |
Correct |
270 ms |
348292 KB |
Output is correct |
59 |
Correct |
3 ms |
7380 KB |
Output is correct |
60 |
Correct |
4 ms |
7380 KB |
Output is correct |
61 |
Correct |
3 ms |
7372 KB |
Output is correct |
62 |
Correct |
3 ms |
7380 KB |
Output is correct |
63 |
Correct |
5 ms |
7380 KB |
Output is correct |
64 |
Correct |
5 ms |
7380 KB |
Output is correct |
65 |
Correct |
4 ms |
7380 KB |
Output is correct |
66 |
Correct |
6 ms |
7376 KB |
Output is correct |
67 |
Correct |
4 ms |
7380 KB |
Output is correct |
68 |
Correct |
5 ms |
7380 KB |
Output is correct |
69 |
Correct |
3 ms |
7380 KB |
Output is correct |
70 |
Correct |
4 ms |
7508 KB |
Output is correct |
71 |
Correct |
6 ms |
7380 KB |
Output is correct |
72 |
Correct |
4 ms |
7508 KB |
Output is correct |
73 |
Correct |
4 ms |
7636 KB |
Output is correct |
74 |
Correct |
4 ms |
7500 KB |
Output is correct |
75 |
Correct |
6 ms |
7448 KB |
Output is correct |
76 |
Correct |
5 ms |
7500 KB |
Output is correct |
77 |
Correct |
5 ms |
7512 KB |
Output is correct |
78 |
Correct |
4 ms |
7484 KB |
Output is correct |
79 |
Incorrect |
4 ms |
7380 KB |
Output isn't correct |
80 |
Halted |
0 ms |
0 KB |
- |