97732024-03-06 15:49:36FulopMateEmezen Rt.cpp17Accepted 100/10093ms18504 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;

int n, m;
vector<vector<int>> g;
vector<bool> v;

void solve(){
    cin>>n>>m;
    g.assign(n+1, {});
    v.assign(n+1, 0);
    for(int i = 0; i < m; i++){
        int a, b; cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> ans;
    for(int i = 1; i <= n; i++){
        int c0 = 0, c1 = 0;
        for(int j : g[i]){
            if(j > i)continue;
            if(v[j])c1++;
            else c0++;
        }
        if(c0 > c1){
            v[i] = 1;
            ans.push_back(i);
        }
    }
    cout<<ans.size()<<endl;
    for(int i:ans)cout<<i<<" ";
    cout<<endl;
}


// 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
1Accepted3ms1832 KiB
subtask216/16
2Accepted3ms2016 KiB
3Accepted3ms2236 KiB
4Accepted3ms2452 KiB
5Accepted3ms2560 KiB
6Accepted3ms2776 KiB
7Accepted3ms2868 KiB
8Accepted3ms3000 KiB
9Accepted3ms3084 KiB
10Accepted3ms3212 KiB
11Accepted3ms3544 KiB
12Accepted3ms3684 KiB
13Accepted3ms3772 KiB
14Accepted3ms4008 KiB
15Accepted3ms4220 KiB
16Accepted3ms4196 KiB
subtask318/18
17Accepted23ms6536 KiB
18Accepted46ms10220 KiB
19Accepted46ms8900 KiB
20Accepted7ms9028 KiB
21Accepted43ms14816 KiB
22Accepted57ms16688 KiB
23Accepted78ms14432 KiB
24Accepted78ms16356 KiB
25Accepted82ms18152 KiB
26Accepted86ms18504 KiB
subtask466/66
27Accepted8ms10212 KiB
28Accepted14ms11764 KiB
29Accepted29ms13708 KiB
30Accepted68ms16864 KiB
31Accepted89ms18236 KiB
32Accepted90ms18312 KiB
33Accepted86ms17560 KiB
34Accepted86ms16808 KiB
35Accepted50ms10224 KiB
36Accepted50ms10028 KiB
37Accepted3ms4848 KiB
38Accepted4ms5100 KiB
39Accepted9ms5588 KiB
40Accepted3ms5068 KiB
41Accepted3ms5048 KiB
42Accepted93ms5252 KiB
43Accepted35ms5312 KiB
44Accepted7ms5320 KiB
45Accepted3ms5388 KiB