#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cmin(a, b) a=min(a, b)
#define cmax(a, b) a=max(a, b)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int long long
void solve();
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
solve();
return 0;
}
vector<vector<int>> vec;
void print() {
cout << sz(vec) << endl;
for (auto &a: vec) {
for (auto &u: a) cout << u << ' ';
cout << endl;
}
cout << endl;
}
void add(vector<int> &a) { vec.pb(a); }
int n, m;
vector<int> a, cnt;
vector<vector<int>> adj;
vector<bool> visited, visited2, ok, tovisit;
bool dfs(int x) {
bool flag=0;
if (ok[x]) flag=1;
visited2[x]=1;
for (auto u: adj[x]) if (!visited[u] && !visited2[u]) {
flag|=dfs(u);
}
return tovisit[x]=flag;
}
void dfs2(int x) {
visited[x]=1;
cnt[x]++;
for (auto u: adj[x]) if (!visited[u]) {
visited2.clear(), visited2.resize(n, 0);
tovisit.clear(), tovisit.resize(n, 0);
dfs(u);
if (tovisit[u]) dfs2(u);
}
}
void execute(int x) {
visited[x]=1;
for (auto u: adj[x]) if (!visited[u]) {
visited2.clear(), visited2.resize(n, 0);
tovisit.clear(), tovisit.resize(n, 0);
dfs(u);
if (tovisit[u]) {
auto temp=a; temp[x]=0, temp[u]=0;
add(temp);
execute(u);
add(temp);
}
}
}
void solve() {
cin >> n >> m; a.clear(), a.resize(n, 0); iota(all(a), 1);
adj.clear(), adj.resize(n), ok.clear(), ok.resize(n, 1);
vector<set<int>> adjbase(n);
for (int i=0; i<m; i++) {
int u, v; cin >> u >> v;
adj[u].pb(v), adj[v].pb(u);
adjbase[u].insert(v), adjbase[v].insert(u);
}
for (int i=0; i<n-1; i++) {
int best=-1;
cnt.clear(), cnt.resize(n);
for (int j=0; j<n; j++) {
visited.clear(), visited.resize(n);
dfs2(j);
}
for (int j=0; j<n; j++) if (ok[j] && (best==-1 || cnt[j]<cnt[best])) best=j;
visited.clear(), visited.resize(n, 0);
execute(best);
ok[best]=0;
for (auto u: adjbase[best]) {
adjbase[u].erase(best);
}
adjbase[best].clear();
}
print();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Partially correct |
114 ms |
11148 KB |
Partially correct |
5 |
Partially correct |
122 ms |
11652 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
3 ms |
336 KB |
Output is correct |
6 |
Partially correct |
51 ms |
980 KB |
Partially correct |
7 |
Partially correct |
191 ms |
1544 KB |
Partially correct |
8 |
Partially correct |
462 ms |
3144 KB |
Partially correct |
9 |
Execution timed out |
9050 ms |
13852 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Partially correct |
22 ms |
1616 KB |
Partially correct |
5 |
Partially correct |
270 ms |
10884 KB |
Partially correct |
6 |
Partially correct |
277 ms |
11496 KB |
Partially correct |
7 |
Partially correct |
62 ms |
3364 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Partially correct |
114 ms |
11148 KB |
Partially correct |
5 |
Partially correct |
122 ms |
11652 KB |
Partially correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Partially correct |
22 ms |
1616 KB |
Partially correct |
10 |
Partially correct |
270 ms |
10884 KB |
Partially correct |
11 |
Partially correct |
277 ms |
11496 KB |
Partially correct |
12 |
Partially correct |
62 ms |
3364 KB |
Partially correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Partially correct |
115 ms |
11140 KB |
Partially correct |
17 |
Partially correct |
102 ms |
11576 KB |
Partially correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Partially correct |
24 ms |
1616 KB |
Partially correct |
21 |
Partially correct |
266 ms |
11044 KB |
Partially correct |
22 |
Partially correct |
276 ms |
11396 KB |
Partially correct |
23 |
Partially correct |
56 ms |
3144 KB |
Partially correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Partially correct |
168 ms |
16940 KB |
Partially correct |
28 |
Partially correct |
215 ms |
11652 KB |
Partially correct |
29 |
Partially correct |
204 ms |
11872 KB |
Partially correct |
30 |
Partially correct |
118 ms |
12932 KB |
Partially correct |
31 |
Partially correct |
182 ms |
18064 KB |
Partially correct |
32 |
Partially correct |
231 ms |
12648 KB |
Partially correct |
33 |
Partially correct |
213 ms |
12420 KB |
Partially correct |
34 |
Partially correct |
251 ms |
11652 KB |
Partially correct |
35 |
Partially correct |
276 ms |
19476 KB |
Partially correct |
36 |
Partially correct |
199 ms |
14296 KB |
Partially correct |
37 |
Partially correct |
109 ms |
11920 KB |
Partially correct |
38 |
Partially correct |
203 ms |
14888 KB |
Partially correct |
39 |
Partially correct |
243 ms |
19424 KB |
Partially correct |
40 |
Partially correct |
223 ms |
11652 KB |
Partially correct |
41 |
Partially correct |
178 ms |
17496 KB |
Partially correct |
42 |
Partially correct |
122 ms |
12676 KB |
Partially correct |
43 |
Partially correct |
136 ms |
15500 KB |
Partially correct |
44 |
Partially correct |
379 ms |
18824 KB |
Partially correct |
45 |
Partially correct |
280 ms |
19200 KB |
Partially correct |
46 |
Correct |
1 ms |
336 KB |
Output is correct |
47 |
Correct |
1 ms |
336 KB |
Output is correct |
48 |
Correct |
1 ms |
336 KB |
Output is correct |
49 |
Correct |
1 ms |
336 KB |
Output is correct |
50 |
Correct |
1 ms |
336 KB |
Output is correct |
51 |
Correct |
1 ms |
336 KB |
Output is correct |
52 |
Correct |
1 ms |
336 KB |
Output is correct |
53 |
Correct |
1 ms |
336 KB |
Output is correct |
54 |
Correct |
1 ms |
504 KB |
Output is correct |
55 |
Correct |
1 ms |
336 KB |
Output is correct |
56 |
Correct |
1 ms |
504 KB |
Output is correct |
57 |
Correct |
1 ms |
336 KB |
Output is correct |
58 |
Correct |
1 ms |
428 KB |
Output is correct |
59 |
Correct |
1 ms |
336 KB |
Output is correct |
60 |
Correct |
1 ms |
336 KB |
Output is correct |
61 |
Correct |
1 ms |
500 KB |
Output is correct |
62 |
Correct |
1 ms |
336 KB |
Output is correct |
63 |
Correct |
1 ms |
336 KB |
Output is correct |
64 |
Correct |
1 ms |
336 KB |
Output is correct |
65 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Partially correct |
114 ms |
11148 KB |
Partially correct |
5 |
Partially correct |
122 ms |
11652 KB |
Partially correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
2 ms |
336 KB |
Output is correct |
10 |
Correct |
3 ms |
336 KB |
Output is correct |
11 |
Partially correct |
51 ms |
980 KB |
Partially correct |
12 |
Partially correct |
191 ms |
1544 KB |
Partially correct |
13 |
Partially correct |
462 ms |
3144 KB |
Partially correct |
14 |
Execution timed out |
9050 ms |
13852 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |