218772026-01-14 09:45:08szabelrHálózati biztonság (50)cpp17Elfogadva 50/5079ms7040 KiB
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<int>> adj(n+1);
    vector<int> indegree(n+1,0);
    for(int i=0; i<m; i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
        indegree[x]++;
        indegree[y]++;
    }
    queue<int> q;
    int res=n;
    vector<bool> seen(n+1,false);
    for(int i=1; i<=n; i++)
    {
        if(indegree[i]<k)
        {
            res--;
            seen[i]=true;
            q.push(i);
        }
    }
    while(!q.empty())
    {
        int v=q.front();
        q.pop();
        for(auto next:adj[v])
        {
            if(!seen[next])
            {
                indegree[next]--;
                if(indegree[next]<k)
                {
                    res--;
                    seen[next]=true;
                    q.push(next);
                }
            }
        }
    }
    cout<<res<<endl;
    for(int i=1; i<=n; i++)
    {
        if(!seen[i])
            cout<<i<<" ";
    }
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/02ms316 KiB
2Elfogadva0/043ms3804 KiB
3Elfogadva2/22ms316 KiB
4Elfogadva2/22ms548 KiB
5Elfogadva2/21ms316 KiB
6Elfogadva2/21ms316 KiB
7Elfogadva2/21ms316 KiB
8Elfogadva2/21ms316 KiB
9Elfogadva2/21ms316 KiB
10Elfogadva2/23ms564 KiB
11Elfogadva2/21ms316 KiB
12Elfogadva2/23ms564 KiB
13Elfogadva3/31ms316 KiB
14Elfogadva3/34ms820 KiB
15Elfogadva3/34ms1256 KiB
16Elfogadva3/337ms2976 KiB
17Elfogadva3/34ms1012 KiB
18Elfogadva3/36ms2248 KiB
19Elfogadva3/348ms6200 KiB
20Elfogadva3/379ms7040 KiB
21Elfogadva3/352ms6544 KiB
22Elfogadva3/31ms316 KiB