#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;
vector<set<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 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;
for (int i=0; i<m; i++) {
int u, v; cin >> u >> v;
adj[u].insert(v), adj[v].insert(u);
}
adjbase=adj;
for (int i=0; i<n-1; i++) {
int best=-1;
for (int j=0; j<n; j++) if ((best==-1 && ok[j]) || (sz(adjbase[j])!=0 && sz(adjbase[best])<sz(adjbase[j]))) {
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();
}
# |
결과 |
실행 시간 |
메모리 |
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 |
66 ms |
11140 KB |
Partially correct |
5 |
Partially correct |
73 ms |
11656 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Partially correct |
8 ms |
1104 KB |
Partially correct |
7 |
Partially correct |
21 ms |
1904 KB |
Partially correct |
8 |
Partially correct |
45 ms |
3144 KB |
Partially correct |
9 |
Partially correct |
690 ms |
22784 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
352 KB |
Output is correct |
4 |
Partially correct |
19 ms |
2384 KB |
Partially correct |
5 |
Partially correct |
112 ms |
16256 KB |
Partially correct |
6 |
Partially correct |
102 ms |
17028 KB |
Partially correct |
7 |
Partially correct |
31 ms |
4680 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
66 ms |
11140 KB |
Partially correct |
5 |
Partially correct |
73 ms |
11656 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 |
352 KB |
Output is correct |
9 |
Partially correct |
19 ms |
2384 KB |
Partially correct |
10 |
Partially correct |
112 ms |
16256 KB |
Partially correct |
11 |
Partially correct |
102 ms |
17028 KB |
Partially correct |
12 |
Partially correct |
31 ms |
4680 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 |
102 ms |
11160 KB |
Partially correct |
17 |
Partially correct |
72 ms |
11700 KB |
Partially correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Partially correct |
23 ms |
2256 KB |
Partially correct |
21 |
Partially correct |
136 ms |
16180 KB |
Partially correct |
22 |
Partially correct |
104 ms |
17028 KB |
Partially correct |
23 |
Partially correct |
37 ms |
4844 KB |
Partially correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
2 ms |
504 KB |
Output is correct |
27 |
Partially correct |
120 ms |
18128 KB |
Partially correct |
28 |
Partially correct |
128 ms |
16516 KB |
Partially correct |
29 |
Partially correct |
103 ms |
16612 KB |
Partially correct |
30 |
Partially correct |
82 ms |
13700 KB |
Partially correct |
31 |
Partially correct |
115 ms |
18908 KB |
Partially correct |
32 |
Partially correct |
119 ms |
17176 KB |
Partially correct |
33 |
Partially correct |
102 ms |
17284 KB |
Partially correct |
34 |
Partially correct |
101 ms |
16964 KB |
Partially correct |
35 |
Partially correct |
120 ms |
19456 KB |
Partially correct |
36 |
Partially correct |
99 ms |
14468 KB |
Partially correct |
37 |
Partially correct |
66 ms |
11740 KB |
Partially correct |
38 |
Partially correct |
82 ms |
14748 KB |
Partially correct |
39 |
Partially correct |
109 ms |
19236 KB |
Partially correct |
40 |
Partially correct |
123 ms |
16292 KB |
Partially correct |
41 |
Partially correct |
97 ms |
17540 KB |
Partially correct |
42 |
Partially correct |
76 ms |
12676 KB |
Partially correct |
43 |
Partially correct |
96 ms |
15332 KB |
Partially correct |
44 |
Partially correct |
128 ms |
20408 KB |
Partially correct |
45 |
Partially correct |
135 ms |
19776 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 |
512 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 |
2 ms |
336 KB |
Output is correct |
55 |
Correct |
1 ms |
508 KB |
Output is correct |
56 |
Correct |
2 ms |
508 KB |
Output is correct |
57 |
Correct |
1 ms |
336 KB |
Output is correct |
58 |
Correct |
1 ms |
512 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 |
336 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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
66 ms |
11140 KB |
Partially correct |
5 |
Partially correct |
73 ms |
11656 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 |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Partially correct |
8 ms |
1104 KB |
Partially correct |
12 |
Partially correct |
21 ms |
1904 KB |
Partially correct |
13 |
Partially correct |
45 ms |
3144 KB |
Partially correct |
14 |
Partially correct |
690 ms |
22784 KB |
Partially correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
352 KB |
Output is correct |
18 |
Partially correct |
19 ms |
2384 KB |
Partially correct |
19 |
Partially correct |
112 ms |
16256 KB |
Partially correct |
20 |
Partially correct |
102 ms |
17028 KB |
Partially correct |
21 |
Partially correct |
31 ms |
4680 KB |
Partially correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Partially correct |
102 ms |
11160 KB |
Partially correct |
26 |
Partially correct |
72 ms |
11700 KB |
Partially correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Partially correct |
23 ms |
2256 KB |
Partially correct |
30 |
Partially correct |
136 ms |
16180 KB |
Partially correct |
31 |
Partially correct |
104 ms |
17028 KB |
Partially correct |
32 |
Partially correct |
37 ms |
4844 KB |
Partially correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
2 ms |
504 KB |
Output is correct |
36 |
Partially correct |
120 ms |
18128 KB |
Partially correct |
37 |
Partially correct |
128 ms |
16516 KB |
Partially correct |
38 |
Partially correct |
103 ms |
16612 KB |
Partially correct |
39 |
Partially correct |
82 ms |
13700 KB |
Partially correct |
40 |
Partially correct |
115 ms |
18908 KB |
Partially correct |
41 |
Partially correct |
119 ms |
17176 KB |
Partially correct |
42 |
Partially correct |
102 ms |
17284 KB |
Partially correct |
43 |
Partially correct |
101 ms |
16964 KB |
Partially correct |
44 |
Partially correct |
120 ms |
19456 KB |
Partially correct |
45 |
Partially correct |
99 ms |
14468 KB |
Partially correct |
46 |
Partially correct |
66 ms |
11740 KB |
Partially correct |
47 |
Partially correct |
82 ms |
14748 KB |
Partially correct |
48 |
Partially correct |
109 ms |
19236 KB |
Partially correct |
49 |
Partially correct |
123 ms |
16292 KB |
Partially correct |
50 |
Partially correct |
97 ms |
17540 KB |
Partially correct |
51 |
Partially correct |
76 ms |
12676 KB |
Partially correct |
52 |
Partially correct |
96 ms |
15332 KB |
Partially correct |
53 |
Partially correct |
128 ms |
20408 KB |
Partially correct |
54 |
Partially correct |
135 ms |
19776 KB |
Partially correct |
55 |
Correct |
1 ms |
336 KB |
Output is correct |
56 |
Correct |
1 ms |
336 KB |
Output is correct |
57 |
Correct |
1 ms |
336 KB |
Output is correct |
58 |
Correct |
1 ms |
512 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 |
336 KB |
Output is correct |
62 |
Correct |
1 ms |
336 KB |
Output is correct |
63 |
Correct |
2 ms |
336 KB |
Output is correct |
64 |
Correct |
1 ms |
508 KB |
Output is correct |
65 |
Correct |
2 ms |
508 KB |
Output is correct |
66 |
Correct |
1 ms |
336 KB |
Output is correct |
67 |
Correct |
1 ms |
512 KB |
Output is correct |
68 |
Correct |
1 ms |
336 KB |
Output is correct |
69 |
Correct |
1 ms |
336 KB |
Output is correct |
70 |
Correct |
1 ms |
336 KB |
Output is correct |
71 |
Correct |
1 ms |
336 KB |
Output is correct |
72 |
Correct |
1 ms |
336 KB |
Output is correct |
73 |
Correct |
1 ms |
336 KB |
Output is correct |
74 |
Correct |
1 ms |
336 KB |
Output is correct |
75 |
Correct |
1 ms |
336 KB |
Output is correct |
76 |
Correct |
1 ms |
336 KB |
Output is correct |
77 |
Correct |
1 ms |
336 KB |
Output is correct |
78 |
Partially correct |
79 ms |
11212 KB |
Partially correct |
79 |
Partially correct |
81 ms |
11664 KB |
Partially correct |
80 |
Correct |
1 ms |
336 KB |
Output is correct |
81 |
Correct |
1 ms |
336 KB |
Output is correct |
82 |
Correct |
1 ms |
336 KB |
Output is correct |
83 |
Correct |
2 ms |
336 KB |
Output is correct |
84 |
Partially correct |
9 ms |
1104 KB |
Partially correct |
85 |
Partially correct |
21 ms |
1888 KB |
Partially correct |
86 |
Partially correct |
45 ms |
3304 KB |
Partially correct |
87 |
Partially correct |
758 ms |
22840 KB |
Partially correct |
88 |
Correct |
1 ms |
336 KB |
Output is correct |
89 |
Correct |
1 ms |
336 KB |
Output is correct |
90 |
Partially correct |
15 ms |
2384 KB |
Partially correct |
91 |
Partially correct |
136 ms |
16260 KB |
Partially correct |
92 |
Partially correct |
110 ms |
16968 KB |
Partially correct |
93 |
Partially correct |
40 ms |
4840 KB |
Partially correct |
94 |
Correct |
1 ms |
336 KB |
Output is correct |
95 |
Correct |
1 ms |
336 KB |
Output is correct |
96 |
Correct |
2 ms |
592 KB |
Output is correct |
97 |
Partially correct |
115 ms |
18052 KB |
Partially correct |
98 |
Partially correct |
116 ms |
16516 KB |
Partially correct |
99 |
Partially correct |
105 ms |
16516 KB |
Partially correct |
100 |
Partially correct |
81 ms |
13700 KB |
Partially correct |
101 |
Partially correct |
118 ms |
18944 KB |
Partially correct |
102 |
Partially correct |
107 ms |
17028 KB |
Partially correct |
103 |
Partially correct |
117 ms |
17484 KB |
Partially correct |
104 |
Partially correct |
104 ms |
16944 KB |
Partially correct |
105 |
Partially correct |
118 ms |
19460 KB |
Partially correct |
106 |
Partially correct |
92 ms |
14240 KB |
Partially correct |
107 |
Partially correct |
69 ms |
11916 KB |
Partially correct |
108 |
Partially correct |
97 ms |
14748 KB |
Partially correct |
109 |
Partially correct |
110 ms |
19312 KB |
Partially correct |
110 |
Partially correct |
99 ms |
16484 KB |
Partially correct |
111 |
Partially correct |
96 ms |
17540 KB |
Partially correct |
112 |
Partially correct |
76 ms |
12676 KB |
Partially correct |
113 |
Partially correct |
86 ms |
15500 KB |
Partially correct |
114 |
Partially correct |
130 ms |
20480 KB |
Partially correct |
115 |
Partially correct |
141 ms |
19936 KB |
Partially correct |
116 |
Correct |
1 ms |
336 KB |
Output is correct |
117 |
Correct |
1 ms |
336 KB |
Output is correct |
118 |
Correct |
1 ms |
336 KB |
Output is correct |
119 |
Correct |
1 ms |
336 KB |
Output is correct |
120 |
Correct |
1 ms |
336 KB |
Output is correct |
121 |
Correct |
1 ms |
336 KB |
Output is correct |
122 |
Correct |
2 ms |
336 KB |
Output is correct |
123 |
Correct |
1 ms |
336 KB |
Output is correct |
124 |
Correct |
1 ms |
336 KB |
Output is correct |
125 |
Correct |
1 ms |
336 KB |
Output is correct |
126 |
Correct |
1 ms |
336 KB |
Output is correct |
127 |
Correct |
1 ms |
336 KB |
Output is correct |
128 |
Correct |
1 ms |
336 KB |
Output is correct |
129 |
Correct |
1 ms |
428 KB |
Output is correct |
130 |
Correct |
1 ms |
336 KB |
Output is correct |
131 |
Correct |
1 ms |
504 KB |
Output is correct |
132 |
Correct |
1 ms |
336 KB |
Output is correct |
133 |
Correct |
1 ms |
336 KB |
Output is correct |
134 |
Correct |
1 ms |
336 KB |
Output is correct |
135 |
Correct |
2 ms |
336 KB |
Output is correct |
136 |
Correct |
1 ms |
336 KB |
Output is correct |
137 |
Correct |
2 ms |
336 KB |
Output is correct |
138 |
Correct |
2 ms |
336 KB |
Output is correct |
139 |
Correct |
1 ms |
488 KB |
Output is correct |
140 |
Partially correct |
121 ms |
18272 KB |
Partially correct |
141 |
Correct |
1 ms |
336 KB |
Output is correct |
142 |
Partially correct |
964 ms |
22540 KB |
Partially correct |
143 |
Partially correct |
966 ms |
22272 KB |
Partially correct |
144 |
Partially correct |
646 ms |
22612 KB |
Partially correct |
145 |
Partially correct |
462 ms |
22556 KB |
Partially correct |
146 |
Partially correct |
248 ms |
22272 KB |
Partially correct |
147 |
Partially correct |
142 ms |
21428 KB |
Partially correct |
148 |
Partially correct |
423 ms |
22528 KB |
Partially correct |
149 |
Partially correct |
276 ms |
18688 KB |
Partially correct |
150 |
Partially correct |
228 ms |
22272 KB |
Partially correct |
151 |
Partially correct |
188 ms |
22272 KB |
Partially correct |
152 |
Partially correct |
153 ms |
22284 KB |
Partially correct |
153 |
Partially correct |
146 ms |
22016 KB |
Partially correct |
154 |
Partially correct |
334 ms |
22272 KB |
Partially correct |
155 |
Partially correct |
101 ms |
15380 KB |
Partially correct |
156 |
Partially correct |
151 ms |
21968 KB |
Partially correct |
157 |
Partially correct |
69 ms |
11908 KB |
Partially correct |
158 |
Partially correct |
110 ms |
18308 KB |
Partially correct |
159 |
Partially correct |
170 ms |
22132 KB |
Partially correct |
160 |
Partially correct |
133 ms |
21504 KB |
Partially correct |
161 |
Partially correct |
118 ms |
18688 KB |
Partially correct |
162 |
Correct |
1 ms |
336 KB |
Output is correct |
163 |
Correct |
1 ms |
336 KB |
Output is correct |
164 |
Correct |
1 ms |
336 KB |
Output is correct |
165 |
Correct |
1 ms |
336 KB |
Output is correct |