#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair <int, int>
#define sz(a) (int)(a.size())
#define resize(v) v.resize(unique(all(v)) - v.begin());
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
using namespace std;
void Fast_Read_Out()
{
ios_base::sync_with_stdio(0);
cin.tie(), cout.tie();
}
void Random()
{
unsigned int seed;
asm("rdtsc" : "=A" (seed));
srand(seed);
}
unsigned int Time()
{
unsigned int time = clock() / 1000.00;
return time;
}
const int inf = int(1e9) + 123;
const int N = int(1e3) + 123;
int st;
int d[1001][1001], sor[1001], ok = 1, a[1001], dd[1001];
vector <int> res, g[N];
bool Check()
{
res.pb(res[0]);
for(int i = 0; i < sz(res) - 1; i++)
{
if(d[res[i]][res[i + 1]]) continue;
else return 0;
}
for(int i = 0; i < sz(res); i++) dd[res[i]]++;
for(int i = 0; i < sz(res) - 1; i++)
{
for(int j = 0; j < sz(g[res[i]]); j++) if(dd[g[res[i]][j]] && j != res[i + 1]) return 0;
}
return 1;
}
int main ()
{
#ifdef JUDGE
freopen("input.txt", "r", stdin);
#endif
Random();
Fast_Read_Out();
int n, m;
cin >> n >> m;
for(int i = 1; i <= m; i++)
{
int a, b;
cin >> a >> b;
d[a][b]++;
d[b][a]++;
g[a].pb(b);
g[b].pb(a);
}
for(int i = 1; i <= n; i++) sor[i] = i;
do
{
int j = 1;
for(int len = 4; len <= n;)
{
int j1 = j;
while(j1 <= j + len && j1 <= n)
{
res.pb(sor[j1]);
j1++;
}
if(Check())
{
for(int i = 0; i < sz(res) - 1; i++)
{
cout << res[i] << ' ';
}
return 0;
}
else res.clear();
if(j + len == n) len++;
else j++;
}
for(int i = 1; i <= n; i++) cout << sor[i] << ' ';
cout << endl;
}while(next_permutation(a + 1, a + n + 1));
cout << "no" << endl;
#ifdef JUDGE
// cout << Time() << endl;
#endif
}
// Easy Peasy Lemon Squeezy Sometimes it's the very people who no one imagines anything of who do the things no one can imagine.
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
380 KB |
Too short sequence |
2 |
Incorrect |
2 ms |
380 KB |
Unexpected end of file - token expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
536 KB |
Too short sequence |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
596 KB |
Too short sequence |
2 |
Incorrect |
2 ms |
596 KB |
Unexpected end of file - token expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
944 KB |
Too short sequence |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
944 KB |
Too short sequence |
2 |
Incorrect |
2 ms |
944 KB |
Unexpected end of file - token expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1848 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1848 KB |
Too short sequence |
2 |
Incorrect |
4 ms |
1848 KB |
Unexpected end of file - token expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
5136 KB |
Too short sequence |
2 |
Correct |
10 ms |
5136 KB |
Too short sequence |
3 |
Incorrect |
21 ms |
5600 KB |
Unexpected end of file - token expected |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
5600 KB |
Too short sequence |
2 |
Incorrect |
11 ms |
5600 KB |
Unexpected end of file - token expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
5600 KB |
Too short sequence |
2 |
Incorrect |
24 ms |
5600 KB |
Unexpected end of file - token expected |
3 |
Halted |
0 ms |
0 KB |
- |