9772 | 2024-03-06 14:06:18 | FulopMate | Emezen Rt. | cpp17 | Accepted 100/100 | 64ms | 13640 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX(a, b) (a) = max((a), (b))
#define MIN(a, b) (a) = min((a), (b))
#define all(a) (a).begin(), (a).end()
#define sortedpair(a, b) {min((a), (b)), max((a), (b))}
const ll MOD = 1e9+7;
const int MAXN = 100'001;
struct E {
int u, v, w;
E(int a, int b, int c) : u(a), v(b), w(c) {}
};
int ans[MAXN];
vector<int> g[MAXN];
void solve(){
int n, m; cin>>n>>m;
vector<pair<int, int>> edges;
for (int i = 0; i < m; i++) {
int u, v; cin >> u >> v;
edges.emplace_back(u, v);
}
while (true) {
for (int i = 1; i <= n; i++) {
ans[i] = rand()&1;
}
int ok = 0;
for (auto [u, v] : edges) {
if (ans[u] == ans[v]) ok++;
}
if (ok <= m/2) {
break;
}
}
cout << count(ans+1, ans+n+1, 1) << "\n";
for (int i = 1; i <= n; i++) {
if (ans[i]) cout << i << " ";
}
cout << "\n";
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int _t = 1;
cin >> _t;
while (_t--) {
solve();
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 4ms | 6616 KiB | ||||
subtask2 | 16/16 | ||||||
2 | Accepted | 4ms | 6908 KiB | ||||
3 | Accepted | 4ms | 7016 KiB | ||||
4 | Accepted | 4ms | 7228 KiB | ||||
5 | Accepted | 4ms | 7436 KiB | ||||
6 | Accepted | 4ms | 7648 KiB | ||||
7 | Accepted | 4ms | 7868 KiB | ||||
8 | Accepted | 4ms | 7824 KiB | ||||
9 | Accepted | 4ms | 8120 KiB | ||||
10 | Accepted | 4ms | 8196 KiB | ||||
11 | Accepted | 4ms | 8244 KiB | ||||
12 | Accepted | 4ms | 8208 KiB | ||||
13 | Accepted | 4ms | 8172 KiB | ||||
14 | Accepted | 4ms | 8136 KiB | ||||
15 | Accepted | 4ms | 8428 KiB | ||||
16 | Accepted | 4ms | 8428 KiB | ||||
subtask3 | 18/18 | ||||||
17 | Accepted | 24ms | 10768 KiB | ||||
18 | Accepted | 45ms | 13000 KiB | ||||
19 | Accepted | 46ms | 12952 KiB | ||||
20 | Accepted | 13ms | 10080 KiB | ||||
21 | Accepted | 46ms | 11540 KiB | ||||
22 | Accepted | 50ms | 13380 KiB | ||||
23 | Accepted | 54ms | 13332 KiB | ||||
24 | Accepted | 57ms | 13296 KiB | ||||
25 | Accepted | 63ms | 13308 KiB | ||||
26 | Accepted | 63ms | 13332 KiB | ||||
subtask4 | 66/66 | ||||||
27 | Accepted | 14ms | 10292 KiB | ||||
28 | Accepted | 27ms | 10496 KiB | ||||
29 | Accepted | 30ms | 10828 KiB | ||||
30 | Accepted | 59ms | 13296 KiB | ||||
31 | Accepted | 57ms | 13312 KiB | ||||
32 | Accepted | 57ms | 13312 KiB | ||||
33 | Accepted | 57ms | 13292 KiB | ||||
34 | Accepted | 64ms | 13292 KiB | ||||
35 | Accepted | 46ms | 13288 KiB | ||||
36 | Accepted | 46ms | 13640 KiB | ||||
37 | Accepted | 4ms | 9440 KiB | ||||
38 | Accepted | 6ms | 9804 KiB | ||||
39 | Accepted | 12ms | 10120 KiB | ||||
40 | Accepted | 4ms | 9568 KiB | ||||
41 | Accepted | 4ms | 9608 KiB | ||||
42 | Accepted | 46ms | 9632 KiB | ||||
43 | Accepted | 21ms | 9512 KiB | ||||
44 | Accepted | 10ms | 9564 KiB | ||||
45 | Accepted | 9ms | 9628 KiB |