146102025-01-20 19:38:02tomi7Hálózati biztonság (50)cpp17Wrong answer 7/50162ms7972 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m, k;cin>>n>>m>>k;
	vector<vector<int>> a(n);
	vector<int> c(n); // cardinality of vertexes
	vector<pair<int, int>> o(n);
	for(int i=0;i<m;i++){
		int x, y;cin>>x>>y;
		x--;y--;
		o[x].first++;o[x].second=x;
		o[y].first++;o[y].second=y;
		c[x]++;
		c[y]++;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	queue<int> q;
	vector<bool> visited(n, false);
	for(int i=0;i<n;i++){
		if(o[i].first<k){
			q.push(o[i].second);
			visited[o[i].second]=true;
		}
	}
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(int y: a[x]){
			c[y]--;
			if(c[y]<k){
				if(!visited[y]){
					visited[y]=true;
					q.push(y);
				}
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(!visited[i]){
			ans++;
		}
	}
	cout<<ans<<'\n';
	for(int i=0;i<n;i++){
		if(!visited[i]){
			cout<<i+1<<' ';
		}
	}
}

//21
//3052 7905 7982 9258 11265 14702 17088 17737 20444 24163 25173 28794 30964 32543 35139 41928 43358 45869 47876 48695 48864 
SubtaskSumTestVerdictTimeMemory
base7/50
1Accepted0/01ms316 KiB
2Wrong answer0/090ms4148 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms508 KiB
5Accepted2/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms348 KiB
10Accepted2/26ms568 KiB
11Wrong answer0/22ms316 KiB
12Wrong answer0/24ms564 KiB
13Wrong answer0/32ms328 KiB
14Wrong answer0/36ms824 KiB
15Wrong answer0/38ms1332 KiB
16Wrong answer0/382ms3092 KiB
17Wrong answer0/37ms896 KiB
18Wrong answer0/316ms2868 KiB
19Wrong answer0/3108ms7220 KiB
20Wrong answer0/3162ms7972 KiB
21Wrong answer0/3116ms7144 KiB
22Accepted3/31ms316 KiB