97722024-03-06 14:06:18FulopMateEmezen Rt.cpp17Accepted 100/10064ms13640 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted4ms6616 KiB
subtask216/16
2Accepted4ms6908 KiB
3Accepted4ms7016 KiB
4Accepted4ms7228 KiB
5Accepted4ms7436 KiB
6Accepted4ms7648 KiB
7Accepted4ms7868 KiB
8Accepted4ms7824 KiB
9Accepted4ms8120 KiB
10Accepted4ms8196 KiB
11Accepted4ms8244 KiB
12Accepted4ms8208 KiB
13Accepted4ms8172 KiB
14Accepted4ms8136 KiB
15Accepted4ms8428 KiB
16Accepted4ms8428 KiB
subtask318/18
17Accepted24ms10768 KiB
18Accepted45ms13000 KiB
19Accepted46ms12952 KiB
20Accepted13ms10080 KiB
21Accepted46ms11540 KiB
22Accepted50ms13380 KiB
23Accepted54ms13332 KiB
24Accepted57ms13296 KiB
25Accepted63ms13308 KiB
26Accepted63ms13332 KiB
subtask466/66
27Accepted14ms10292 KiB
28Accepted27ms10496 KiB
29Accepted30ms10828 KiB
30Accepted59ms13296 KiB
31Accepted57ms13312 KiB
32Accepted57ms13312 KiB
33Accepted57ms13292 KiB
34Accepted64ms13292 KiB
35Accepted46ms13288 KiB
36Accepted46ms13640 KiB
37Accepted4ms9440 KiB
38Accepted6ms9804 KiB
39Accepted12ms10120 KiB
40Accepted4ms9568 KiB
41Accepted4ms9608 KiB
42Accepted46ms9632 KiB
43Accepted21ms9512 KiB
44Accepted10ms9564 KiB
45Accepted9ms9628 KiB