36212023-03-01 11:28:05Error42Emezen Rt.cpp17Wrong answer 0/10093ms43940 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 <= m; 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
1Accepted3ms1828 KiB
subtask20/16
2Accepted3ms2184 KiB
3Accepted3ms2300 KiB
4Accepted3ms2640 KiB
5Accepted3ms2604 KiB
6Accepted3ms2736 KiB
7Accepted3ms2828 KiB
8Accepted3ms2824 KiB
9Accepted3ms2952 KiB
10Accepted3ms3160 KiB
11Wrong answer3ms3252 KiB
12Wrong answer3ms3380 KiB
13Wrong answer3ms3724 KiB
14Accepted3ms3840 KiB
15Accepted3ms3904 KiB
16Accepted3ms3688 KiB
subtask30/18
17Wrong answer21ms6972 KiB
18Wrong answer43ms12300 KiB
19Wrong answer43ms12796 KiB
20Accepted8ms13836 KiB
21Accepted48ms20420 KiB
22Runtime error61ms23884 KiB
23Runtime error71ms23332 KiB
24Runtime error68ms27288 KiB
25Runtime error81ms31580 KiB
26Runtime error75ms33764 KiB
subtask40/66
27Wrong answer8ms26340 KiB
28Wrong answer16ms27952 KiB
29Accepted29ms30516 KiB
30Runtime error71ms35260 KiB
31Runtime error92ms38912 KiB
32Runtime error93ms41208 KiB
33Runtime error90ms42584 KiB
34Runtime error86ms43940 KiB
35Wrong answer48ms39120 KiB
36Wrong answer48ms40916 KiB
37Wrong answer3ms35752 KiB
38Accepted4ms36164 KiB
39Wrong answer8ms36992 KiB
40Wrong answer3ms36424 KiB
41Wrong answer3ms36400 KiB
42Accepted48ms36944 KiB
43Wrong answer21ms37308 KiB
44Wrong answer4ms37208 KiB
45Wrong answer3ms37416 KiB