30012023-02-08 07:19:15samatEmezen Rt.cpp11Wrong answer 0/1001.1s26500 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
1Accepted7ms7376 KiB
subtask20/16
2Wrong answer4ms7560 KiB
3Accepted4ms7780 KiB
4Wrong answer4ms7984 KiB
5Wrong answer4ms8148 KiB
6Wrong answer4ms8444 KiB
7Wrong answer4ms8660 KiB
8Wrong answer4ms8872 KiB
9Wrong answer4ms9160 KiB
10Wrong answer6ms9152 KiB
11Wrong answer7ms9264 KiB
12Wrong answer7ms9276 KiB
13Accepted7ms9472 KiB
14Wrong answer8ms9488 KiB
15Wrong answer8ms9608 KiB
16Accepted8ms9492 KiB
subtask30/18
17Accepted54ms11588 KiB
18Accepted112ms15276 KiB
19Accepted115ms14184 KiB
20Wrong answer8ms9688 KiB
21Accepted89ms16396 KiB
22Accepted127ms16916 KiB
23Accepted170ms22528 KiB
24Accepted167ms20404 KiB
25Accepted181ms24744 KiB
26Accepted182ms24096 KiB
subtask40/66
27Wrong answer8ms10324 KiB
28Wrong answer20ms11996 KiB
29Accepted48ms14552 KiB
30Accepted140ms23240 KiB
31Wrong answer180ms26500 KiB
32Wrong answer180ms26244 KiB
33Wrong answer177ms25812 KiB
34Wrong answer175ms25296 KiB
35Wrong answer119ms15804 KiB
36Wrong answer115ms15616 KiB
37Wrong answer6ms10228 KiB
38Wrong answer9ms10480 KiB
39Wrong answer20ms11004 KiB
40Wrong answer6ms10312 KiB
41Wrong answer6ms10352 KiB
42Time limit exceeded1.1s6880 KiB
43Time limit exceeded1.034s6944 KiB
44Wrong answer368ms10456 KiB
45Wrong answer41ms10440 KiB