145262025-01-13 20:26:20tomi7Hálózati biztonság (50)cpp17Wrong answer 7/50175ms7984 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 vertexs
	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);
	}
	sort(o.begin(), o.end());
	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<<' ';
		}
	}
}

SubtaskSumTestVerdictTimeMemory
base7/50
1Accepted0/01ms512 KiB
2Wrong answer0/094ms4140 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Accepted2/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Accepted2/26ms592 KiB
11Wrong answer0/22ms316 KiB
12Wrong answer0/24ms564 KiB
13Wrong answer0/32ms316 KiB
14Wrong answer0/36ms820 KiB
15Wrong answer0/39ms1412 KiB
16Wrong answer0/386ms3264 KiB
17Wrong answer0/37ms820 KiB
18Wrong answer0/317ms2868 KiB
19Wrong answer0/3109ms7040 KiB
20Wrong answer0/3175ms7984 KiB
21Wrong answer0/3118ms7284 KiB
22Accepted3/31ms316 KiB