#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 |
Incorrect |
3 ms |
7380 KB |
Integer parameter [name=k] equals to -2, violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
7252 KB |
Integer parameter [name=k] equals to -2, violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
7380 KB |
Integer parameter [name=k] equals to -2, violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |