36242023-03-01 11:55:17Error42Emezen Rt.cpp17Accepted 100/100103ms18688 KiB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int t;
    cin>>t;
    while(t--)
    {
        int db=0;
        int n,m;
        cin>>n>>m;
        vector<int> state(n+1,0);//1=bolt 2=raktár
        vector<vector<int>>vec(n+1, vector<int>(0, 0));
        for(size_t i  = 0;i<m;i++)
        {
            int u,v;
            cin>>u>>v;
            vec[u].push_back(v);
            vec[v].push_back(u);
        }

        for(int i=1;i<=n;i++)
        {
            int b=0;
            int r=0;
            for(auto j : vec[i])
            {
                if(state[j]==1)
                {
                    b++;
                }
                else if(state[j]==2)
                {
                    r++;
                }
            }
            if(b>r)
            {
                state[i]=2;
                db++;
            }
            if(b<r)
            {
                state[i]=1;
            }
            if(b==r)
            {
                state[i]=2;
                db++;
            }
        }
        cout<<db<<"\n";
        for (size_t i = 1; i <= n; i++)
        {
            if(state[i]==2)
            {
                cout<<i<<" ";
            }
        }
        cout<<"\n";
    }
    
    return 0;
}
/*
2
4 5
1 2
1 3
1 4
2 3
3 4
5 5
1 2
2 3
3 4
4 5
5 1
*/
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1832 KiB
subtask216/16
2Accepted3ms2016 KiB
3Accepted3ms2232 KiB
4Accepted3ms2440 KiB
5Accepted3ms2532 KiB
6Accepted3ms2660 KiB
7Accepted3ms2876 KiB
8Accepted3ms3084 KiB
9Accepted3ms3292 KiB
10Accepted3ms3504 KiB
11Accepted3ms3732 KiB
12Accepted3ms3944 KiB
13Accepted3ms4168 KiB
14Accepted3ms4240 KiB
15Accepted2ms4332 KiB
16Accepted3ms4604 KiB
subtask318/18
17Accepted20ms6968 KiB
18Accepted43ms10560 KiB
19Accepted41ms9220 KiB
20Accepted14ms10152 KiB
21Accepted46ms15680 KiB
22Accepted64ms17300 KiB
23Accepted71ms14228 KiB
24Accepted68ms16200 KiB
25Accepted100ms18364 KiB
26Accepted79ms18368 KiB
subtask466/66
27Accepted16ms11112 KiB
28Accepted21ms12216 KiB
29Accepted35ms14148 KiB
30Accepted74ms17164 KiB
31Accepted103ms18688 KiB
32Accepted92ms18684 KiB
33Accepted86ms18016 KiB
34Accepted85ms17088 KiB
35Accepted46ms10380 KiB
36Accepted46ms10332 KiB
37Accepted3ms5220 KiB
38Accepted4ms5492 KiB
39Accepted8ms5984 KiB
40Accepted3ms5212 KiB
41Accepted3ms5376 KiB
42Accepted48ms5288 KiB
43Accepted23ms5176 KiB
44Accepted8ms5272 KiB
45Accepted7ms5296 KiB