29892023-02-07 12:17:25samatEmezen Rt.cpp11Wrong answer 0/1001.074s25980 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
1Accepted6ms7320 KiB
subtask20/16
2Wrong answer4ms7576 KiB
3Accepted4ms7788 KiB
4Accepted4ms8004 KiB
5Accepted4ms8300 KiB
6Accepted4ms8248 KiB
7Accepted4ms8500 KiB
8Accepted4ms8592 KiB
9Accepted4ms8888 KiB
10Wrong answer6ms9012 KiB
11Wrong answer6ms9116 KiB
12Wrong answer7ms9132 KiB
13Accepted7ms9140 KiB
14Wrong answer7ms9332 KiB
15Wrong answer8ms9548 KiB
16Accepted8ms9400 KiB
subtask30/18
17Accepted56ms11492 KiB
18Accepted115ms15132 KiB
19Accepted118ms14092 KiB
20Wrong answer8ms10060 KiB
21Accepted90ms16532 KiB
22Accepted142ms17036 KiB
23Accepted172ms22364 KiB
24Accepted171ms20208 KiB
25Accepted190ms24448 KiB
26Accepted184ms23796 KiB
subtask40/66
27Wrong answer9ms10168 KiB
28Wrong answer23ms11312 KiB
29Accepted50ms13912 KiB
30Accepted143ms22580 KiB
31Accepted187ms25936 KiB
32Accepted187ms25980 KiB
33Accepted185ms25332 KiB
34Accepted196ms24816 KiB
35Accepted120ms15324 KiB
36Accepted115ms15196 KiB
37Accepted4ms9872 KiB
38Accepted9ms10128 KiB
39Accepted19ms10644 KiB
40Accepted6ms9960 KiB
41Accepted6ms10084 KiB
42Time limit exceeded1.074s6748 KiB
43Time limit exceeded1.07s6612 KiB
44Wrong answer391ms10220 KiB
45Wrong answer46ms10104 KiB