29862023-02-07 12:14:32samatEmezen Rt.cpp11Wrong answer 0/1001.077s25588 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
1Accepted6ms7368 KiB
subtask20/16
2Wrong answer4ms7568 KiB
3Accepted4ms7808 KiB
4Wrong answer4ms8012 KiB
5Wrong answer4ms8188 KiB
6Wrong answer4ms8332 KiB
7Wrong answer4ms8624 KiB
8Wrong answer4ms8844 KiB
9Wrong answer4ms8964 KiB
10Wrong answer6ms9036 KiB
11Wrong answer6ms9120 KiB
12Wrong answer7ms9028 KiB
13Accepted7ms9284 KiB
14Wrong answer7ms9288 KiB
15Wrong answer7ms9172 KiB
16Accepted8ms9160 KiB
subtask30/18
17Accepted54ms11264 KiB
18Accepted112ms14900 KiB
19Accepted118ms14120 KiB
20Wrong answer8ms9520 KiB
21Accepted94ms16280 KiB
22Accepted155ms16800 KiB
23Accepted170ms22164 KiB
24Accepted171ms19792 KiB
25Accepted207ms24208 KiB
26Accepted180ms23560 KiB
subtask40/66
27Wrong answer9ms10128 KiB
28Wrong answer23ms11296 KiB
29Accepted52ms13764 KiB
30Accepted144ms22344 KiB
31Wrong answer196ms25588 KiB
32Wrong answer180ms25464 KiB
33Wrong answer177ms24940 KiB
34Wrong answer175ms24420 KiB
35Wrong answer119ms15192 KiB
36Wrong answer115ms15148 KiB
37Wrong answer6ms9692 KiB
38Wrong answer10ms10200 KiB
39Wrong answer19ms10780 KiB
40Wrong answer4ms10008 KiB
41Wrong answer6ms10032 KiB
42Time limit exceeded1.075s6484 KiB
43Time limit exceeded1.077s6736 KiB
44Wrong answer372ms10264 KiB
45Wrong answer41ms10224 KiB