29902023-02-07 12:18:39samatEmezen Rt.cpp11Wrong answer 0/1001.1s25676 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 * (-1)){
            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 answer6ms7180 KiB
subtask20/16
2Wrong answer4ms7360 KiB
3Accepted4ms7668 KiB
4Wrong answer4ms7868 KiB
5Wrong answer4ms8060 KiB
6Wrong answer4ms8012 KiB
7Wrong answer4ms8220 KiB
8Wrong answer4ms8432 KiB
9Wrong answer4ms8608 KiB
10Wrong answer6ms8872 KiB
11Wrong answer6ms9084 KiB
12Wrong answer6ms9100 KiB
13Wrong answer7ms9296 KiB
14Wrong answer8ms9320 KiB
15Wrong answer8ms9308 KiB
16Wrong answer7ms9316 KiB
subtask30/18
17Accepted54ms11412 KiB
18Accepted112ms15048 KiB
19Accepted115ms14008 KiB
20Wrong answer8ms9456 KiB
21Accepted92ms16348 KiB
22Accepted134ms16948 KiB
23Accepted171ms22280 KiB
24Accepted167ms20064 KiB
25Accepted197ms24356 KiB
26Accepted184ms23708 KiB
subtask40/66
27Wrong answer9ms9936 KiB
28Wrong answer25ms11508 KiB
29Accepted48ms13852 KiB
30Accepted143ms22428 KiB
31Wrong answer206ms25676 KiB
32Wrong answer211ms25676 KiB
33Wrong answer218ms25280 KiB
34Wrong answer174ms24720 KiB
35Wrong answer119ms15232 KiB
36Wrong answer115ms15156 KiB
37Wrong answer6ms9776 KiB
38Wrong answer10ms10288 KiB
39Wrong answer19ms10856 KiB
40Wrong answer6ms9988 KiB
41Wrong answer6ms10236 KiB
42Time limit exceeded1.1s6872 KiB
43Time limit exceeded1.057s6684 KiB
44Wrong answer372ms10216 KiB
45Wrong answer41ms10208 KiB