29882023-02-07 12:16:10samatEmezen Rt.cpp11Wrong answer 0/1001.07s26444 KiB
#include <bits/stdc++.h>

using namespace std;



int n, m, db = 0, t;

void melysegi(vector< vector<int> >& v, vector<bool>& lattam, vector<int>& jelzes, int csucs, int allapot){

    if(!lattam[csucs]){

        lattam[csucs] = true;

        jelzes[csucs] = allapot;

        for(int i = 0; i < v[csucs].size(); i++){

            melysegi(v, lattam, jelzes, v[csucs][i], allapot * (-1));
        }

    }
    else{
        if(jelzes[csucs] == allapot){
            db++;
        }
    }



}

void beolvas(vector< vector<int> >& v){


    cin >> n >> m;

    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;

        v[x].push_back(y);
        v[y].push_back(x);
    }


}

int main()
{
    //ifstream cin("elod.txt");

    cin >> t;

    while(t){

        vector< vector<int> > v(100000);

        vector<bool> lattam(100000, false);

        vector<int> jelzes(100000, 2);

        beolvas(v);


        melysegi(v, lattam, jelzes, 1, 1);

        if(db > m / 2){
            cout << -1 << "\n" << -1 << "\n";
        }
        else{

            int db2 = 0;

            for(int i = 1; i <= n; i++){
                if(jelzes[i] == -1){
                    db2++;
                }
            }

             cout << db2 << "\n";

            for(int i = 1; i <= n; i++){
                if(jelzes[i] == -1){
                    cout << i << " ";
                }
            }

            cout << "\n";

        }
        db = 0;

        t--;
    }



    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer6ms7376 KiB
subtask20/16
2Wrong answer4ms7560 KiB
3Wrong answer4ms7600 KiB
4Wrong answer4ms7972 KiB
5Wrong answer4ms8044 KiB
6Wrong answer4ms8128 KiB
7Wrong answer4ms8420 KiB
8Wrong answer4ms8208 KiB
9Wrong answer4ms8464 KiB
10Wrong answer6ms8728 KiB
11Wrong answer7ms8736 KiB
12Wrong answer7ms8740 KiB
13Wrong answer7ms8932 KiB
14Wrong answer8ms8988 KiB
15Wrong answer7ms8988 KiB
16Wrong answer8ms9144 KiB
subtask30/18
17Wrong answer54ms11264 KiB
18Wrong answer112ms15156 KiB
19Wrong answer115ms14072 KiB
20Wrong answer8ms9832 KiB
21Wrong answer87ms16284 KiB
22Wrong answer127ms16920 KiB
23Wrong answer167ms22500 KiB
24Wrong answer162ms20004 KiB
25Wrong answer177ms24552 KiB
26Wrong answer174ms24128 KiB
subtask40/66
27Wrong answer8ms10436 KiB
28Wrong answer20ms11716 KiB
29Wrong answer48ms14264 KiB
30Wrong answer137ms23092 KiB
31Wrong answer178ms26312 KiB
32Wrong answer201ms26444 KiB
33Wrong answer199ms25880 KiB
34Wrong answer178ms25272 KiB
35Wrong answer119ms15840 KiB
36Wrong answer115ms15652 KiB
37Wrong answer6ms10324 KiB
38Wrong answer10ms10580 KiB
39Wrong answer20ms11100 KiB
40Wrong answer6ms10328 KiB
41Wrong answer7ms10348 KiB
42Time limit exceeded1.036s6964 KiB
43Time limit exceeded1.07s7096 KiB
44Wrong answer368ms10872 KiB
45Wrong answer41ms10648 KiB