30002023-02-08 07:17:50samatEmezen Rt.cpp11Wrong answer 0/1001.075s26396 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 / 4){
            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 answer7ms7444 KiB
subtask20/16
2Wrong answer4ms7520 KiB
3Accepted4ms7648 KiB
4Wrong answer4ms8076 KiB
5Wrong answer4ms8092 KiB
6Wrong answer4ms8160 KiB
7Wrong answer4ms8336 KiB
8Wrong answer4ms8540 KiB
9Wrong answer4ms8496 KiB
10Wrong answer6ms8680 KiB
11Wrong answer6ms8836 KiB
12Wrong answer7ms8856 KiB
13Wrong answer7ms8852 KiB
14Wrong answer8ms8852 KiB
15Wrong answer8ms9048 KiB
16Wrong answer8ms9312 KiB
subtask30/18
17Accepted54ms11724 KiB
18Accepted112ms15184 KiB
19Accepted115ms14492 KiB
20Wrong answer8ms10192 KiB
21Accepted87ms16688 KiB
22Accepted137ms17208 KiB
23Accepted173ms22604 KiB
24Accepted179ms20328 KiB
25Accepted184ms24744 KiB
26Accepted196ms24192 KiB
subtask40/66
27Wrong answer8ms10412 KiB
28Wrong answer21ms11968 KiB
29Accepted50ms14432 KiB
30Wrong answer137ms23108 KiB
31Wrong answer181ms26396 KiB
32Wrong answer184ms26228 KiB
33Wrong answer179ms25708 KiB
34Wrong answer175ms25452 KiB
35Wrong answer118ms15920 KiB
36Wrong answer115ms15700 KiB
37Wrong answer4ms10488 KiB
38Wrong answer10ms10620 KiB
39Wrong answer20ms11140 KiB
40Wrong answer6ms10448 KiB
41Wrong answer6ms10492 KiB
42Time limit exceeded1.075s6944 KiB
43Time limit exceeded1.07s7064 KiB
44Wrong answer391ms10784 KiB
45Wrong answer43ms10764 KiB