42892023-03-22 12:42:51BenceHálózati biztonság (50)cpp11Accepted 50/50153ms18604 KiB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
queue <int> s;

struct adat
{
    int db;
    bool lat;
    vector <int> sz;
};
int n,m,k,i,akt,a,b;

int main()
{
    cin>>n>>m>>k;
    vector <adat> x(n+1);

    for(i=1; i<=m; ++i)
    {
        cin>>a>>b;
        x[a].sz.push_back(b);
        x[b].sz.push_back(a);
    }

    for(i=1; i<=n; ++i)
    {
        x[i].db=x[i].sz.size();
        if(x[i].db<k)
        {
            s.push(i);
            x[i].lat=1;
        }
    }
    while(!s.empty())
    {
        akt=s.front();
        s.pop();
        for(auto &e:x[akt].sz)
        {
            --x[e].db;
            if(x[e].db<k && x[e].lat==0)
            {
                x[e].lat=1;
                s.push(e);
            }
        }
    }

    for(i=1; i<=n; ++i)
    {
        if(x[i].lat==0)
        {
            s.push(i);
        }
    }
    cout<<s.size()<<'\n';

    while(!s.empty())
    {
        cout<<s.front()<<' ';
        s.pop();
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1808 KiB
2Accepted0/087ms9332 KiB
3Accepted2/23ms2336 KiB
4Accepted2/23ms2548 KiB
5Accepted2/23ms2768 KiB
6Accepted2/23ms2880 KiB
7Accepted2/23ms2980 KiB
8Accepted2/23ms3208 KiB
9Accepted2/23ms3300 KiB
10Accepted2/28ms3564 KiB
11Accepted2/23ms3656 KiB
12Accepted2/26ms4160 KiB
13Accepted3/33ms4112 KiB
14Accepted3/37ms5020 KiB
15Accepted3/38ms6200 KiB
16Accepted3/379ms9688 KiB
17Accepted3/38ms5304 KiB
18Accepted3/312ms8536 KiB
19Accepted3/390ms16916 KiB
20Accepted3/3153ms18604 KiB
21Accepted3/3100ms17392 KiB
22Accepted3/33ms4536 KiB