30022023-02-08 07:29:37samatEmezen Rt.cpp11Wrong answer 0/1001.059s25816 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 / 2 > 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
1Accepted7ms7368 KiB
subtask20/16
2Wrong answer4ms7568 KiB
3Accepted4ms7780 KiB
4Accepted4ms8072 KiB
5Accepted4ms8460 KiB
6Accepted4ms8336 KiB
7Accepted4ms8344 KiB
8Accepted4ms8264 KiB
9Accepted4ms8448 KiB
10Wrong answer7ms8704 KiB
11Wrong answer6ms8716 KiB
12Wrong answer7ms9032 KiB
13Accepted7ms9248 KiB
14Wrong answer8ms9148 KiB
15Wrong answer8ms9176 KiB
16Accepted8ms9292 KiB
subtask30/18
17Accepted56ms11388 KiB
18Accepted114ms15284 KiB
19Accepted118ms14208 KiB
20Wrong answer8ms9536 KiB
21Accepted97ms16424 KiB
22Accepted137ms17024 KiB
23Accepted172ms22352 KiB
24Accepted163ms20016 KiB
25Accepted214ms24456 KiB
26Accepted174ms23788 KiB
subtask40/66
27Wrong answer8ms10008 KiB
28Wrong answer20ms11304 KiB
29Accepted52ms13776 KiB
30Accepted145ms22608 KiB
31Accepted225ms25812 KiB
32Accepted228ms25816 KiB
33Accepted216ms25332 KiB
34Accepted196ms24792 KiB
35Accepted123ms15308 KiB
36Accepted119ms15176 KiB
37Accepted6ms9980 KiB
38Accepted9ms10112 KiB
39Accepted21ms10632 KiB
40Accepted6ms9944 KiB
41Accepted7ms10052 KiB
42Time limit exceeded1.059s6556 KiB
43Time limit exceeded1.029s6884 KiB
44Wrong answer412ms10436 KiB
45Wrong answer46ms10448 KiB