87112024-01-26 07:04:26BenedekMartonHálózati biztonság (50)cpp17Accepted 50/50151ms22260 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, m, k, x, y, nc;
    cin >> n >> m >> k;
    bool beve[n+1];
    nc=n;
    vector <int> mat[n+1];
    for(int i=1; i<=m; i++)
    {
        cin >> x >> y;
        mat[x].push_back(y);
        mat[y].push_back(x);
    }
    int foksz[n+1];
    for(int i=1; i<=n; i++)
    {
        foksz[i]=mat[i].size();
        beve[i]=1;
    }
    bool vane=1;
    while(vane)
    {
        vane=0;
        for(int i=1; i<=n; i++)
        {
            if(foksz[i]<k and beve[i])
            {
                nc--;
                vane=1;
                beve[i]=0;
                x=mat[i].size();
                for(int j=0; j<x; j++)
                {
                    foksz[mat[i][j]]--;
                }
            }
        }
    }
    cout << nc << endl;
    for(int i=1; i<=n; i++)
    {
        if(beve[i])
        {
            cout << i << " ";
        }
    }
    //cout << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/082ms9992 KiB
3Accepted2/23ms3364 KiB
4Accepted2/23ms3456 KiB
5Accepted2/23ms3600 KiB
6Accepted2/23ms3808 KiB
7Accepted2/23ms3924 KiB
8Accepted2/23ms4140 KiB
9Accepted2/23ms4240 KiB
10Accepted2/28ms4672 KiB
11Accepted2/24ms4388 KiB
12Accepted2/26ms4652 KiB
13Accepted3/33ms4636 KiB
14Accepted3/37ms5776 KiB
15Accepted3/38ms6556 KiB
16Accepted3/379ms10920 KiB
17Accepted3/38ms6652 KiB
18Accepted3/312ms9492 KiB
19Accepted3/386ms18496 KiB
20Accepted3/3151ms22132 KiB
21Accepted3/394ms22260 KiB
22Accepted3/33ms10588 KiB