29872023-02-07 12:15:20samatEmezen Rt.cpp11Wrong answer 0/1001.1s26236 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
1Accepted7ms7372 KiB
subtask20/16
2Wrong answer4ms7564 KiB
3Accepted4ms7780 KiB
4Wrong answer4ms7736 KiB
5Wrong answer4ms8084 KiB
6Wrong answer4ms8276 KiB
7Wrong answer4ms8372 KiB
8Wrong answer4ms8584 KiB
9Wrong answer4ms8796 KiB
10Wrong answer6ms9056 KiB
11Wrong answer7ms9268 KiB
12Wrong answer7ms9476 KiB
13Accepted7ms9728 KiB
14Wrong answer8ms9900 KiB
15Wrong answer8ms9896 KiB
16Accepted8ms9956 KiB
subtask30/18
17Accepted54ms12056 KiB
18Accepted112ms15660 KiB
19Accepted116ms14620 KiB
20Wrong answer8ms10588 KiB
21Accepted90ms17040 KiB
22Accepted129ms17560 KiB
23Accepted172ms22884 KiB
24Accepted172ms20552 KiB
25Accepted202ms24964 KiB
26Accepted211ms24316 KiB
subtask40/66
27Wrong answer8ms10540 KiB
28Wrong answer20ms11844 KiB
29Accepted48ms14308 KiB
30Accepted143ms23016 KiB
31Wrong answer180ms26236 KiB
32Wrong answer186ms26104 KiB
33Wrong answer179ms25584 KiB
34Wrong answer175ms25072 KiB
35Wrong answer119ms15576 KiB
36Wrong answer115ms15452 KiB
37Wrong answer6ms10120 KiB
38Wrong answer9ms10380 KiB
39Wrong answer19ms10956 KiB
40Wrong answer6ms10208 KiB
41Wrong answer6ms10380 KiB
42Time limit exceeded1.1s7080 KiB
43Time limit exceeded1.057s7028 KiB
44Wrong answer368ms10552 KiB
45Wrong answer41ms10432 KiB