43212023-03-24 12:01:33horvathabelHálózati biztonság (50)cpp17Accepted 50/50170ms61424 KiB
#include <bits/stdc++.h>
using namespace std;
vector<int> g[1000001];
int main() {
	int n, m,k;
	cin>>n>>m>>k;
	vector<int> c(n+1);
	for (int i=0; i<m;i++){
		int x,y;
		cin>>x>>y;
		c[x]++;
		c[y]++;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	queue<int> q; 
	int ans=n; 
	bool seen[1000001];
	for (int i=1; i<=n;i++){
		if (c[i]<k){
			q.push(i);
			ans--;
			seen[i]=true; 
		}
	}
	while (!q.empty()){
		int v=q.front();
		q.pop();
		 for (int edge:g[v]){
			 if (!seen[edge]){
				 c[edge]--;
				 if (c[edge]<k){
					 q.push(edge);
					 seen[edge]=true; 
				 	ans--;
				 }
			 }
		 }
	}
	cout<<ans<<endl; 
	for (int i=1; i<=n;i++){
		if (!seen[i]) cout<<i<<" "; 
	}
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/025ms50672 KiB
2Accepted0/0104ms55672 KiB
3Accepted2/224ms51080 KiB
4Accepted2/224ms51316 KiB
5Accepted2/225ms51272 KiB
6Accepted2/220ms51392 KiB
7Accepted2/224ms51604 KiB
8Accepted2/224ms51692 KiB
9Accepted2/224ms51916 KiB
10Accepted2/229ms52308 KiB
11Accepted2/225ms52032 KiB
12Accepted2/228ms52436 KiB
13Accepted3/325ms52336 KiB
14Accepted3/328ms52760 KiB
15Accepted3/330ms53304 KiB
16Accepted3/3100ms56180 KiB
17Accepted3/329ms52952 KiB
18Accepted3/334ms53972 KiB
19Accepted3/3103ms59772 KiB
20Accepted3/3170ms61424 KiB
21Accepted3/3112ms59984 KiB
22Accepted3/319ms52728 KiB