#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define ios ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
const int N = 1e3 + 5;
const int mod = 1e9 + 7;
const int INF = 1e9;
const double PI = acos(-1.0);
int n, m, a[N][N];
vector < int > g[N], vec;
int main() {
cin >> n >> m;
for (int i = 1, v, u; i <= m; ++i) {
cin >> v >> u;
a[v][u] = 1;
a[u][v] = 1;
g[v].push_back(u);
g[u].push_back(v);
}
for (int i = 1; i <= n; ++i)
vec.push_back(i);
do {
int ok = 1;
for (int i = 1; i < n; ++i) {
if (a[vec[i]][vec[i - 1]] == 0) {
if (i - 1 >= 3 && a[vec[i - 1]][vec[0]]) {
for (int j = 0; j < i; ++j) {
cout << vec[j] << " ";
}
return 0;
}
ok = 0;
break;
}
for (int j = 1; j < i; ++j) {
if (a[vec[i]][vec[j]]) {
ok = 0;
break;
}
}
}
if (ok) {
for (int j : vec)
cout << j << " ";
return 0;
}
} while (next_permutation(vec.begin(), vec.end()));
cout << "no";
}
/**
clock() / (double)CLOCKS_PER_SEC < 1.9
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Expected integer, but "no" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Wrong adjacency |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Wrong adjacency |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1055 ms |
768 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1070 ms |
768 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1071 ms |
1564 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
1664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
4984 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1058 ms |
4728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
58 ms |
3064 KB |
Wrong adjacency |
2 |
Halted |
0 ms |
0 KB |
- |