186542025-10-29 18:54:34KristófHálózati biztonság (50)cpp17Wrong answer 4/50166ms7040 KiB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<int>> graph(n+1);
    queue<int> q;
    vector<int> edge(n+1,0);
    int x,y;
    for(int i=0;i<m;i++)
        {
        cin>>x>>y;
        graph[x].push_back(y);
        graph[y].push_back(x);
        edge[x]++;
        edge[y]++;
        }
    vector<bool> visited(n+1,false);
    for(int i=1;i<=n;i++)
        {
      //  cout<<edge[i]<<" ";
        if(edge[i]<k)
            {
            q.push(i);
            visited[i]=true;
            }
        }

    while(!q.empty())
        {
        int curr=q.front();q.pop();
        //cout<<curr<<" ";
       
        for(auto x : graph[curr])
            {
            if(!visited[x])
                {
                edge[x]--;
                if(edge[x]<k)
                    {
                     visited[curr]=true;
                    q.push(x);
                    }
                }
            }
        }
    vector<int> ans;
    for(int i=1;i<=n;i++)
        {
        if(!visited[i])
            {
            ans.push_back(i);
            }
        }
    cout<<ans.size()<<"\n";
    for(auto x : ans)
        {
        cout<<x<<" ";
        }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/093ms3912 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms512 KiB
5Accepted2/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms500 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Accepted2/26ms516 KiB
11Wrong answer0/22ms316 KiB
12Wrong answer0/24ms564 KiB
13Wrong answer0/31ms316 KiB
14Wrong answer0/34ms832 KiB
15Wrong answer0/37ms1332 KiB
16Wrong answer0/382ms2868 KiB
17Wrong answer0/36ms820 KiB
18Wrong answer0/310ms2220 KiB
19Wrong answer0/389ms6196 KiB
20Wrong answer0/3166ms7040 KiB
21Wrong answer0/3104ms6280 KiB
22Wrong answer0/31ms316 KiB