42622023-03-20 19:35:18horvathabelHálózati biztonság (50)cpp17Wrong answer 0/50151ms17008 KiB
#include <bits/stdc++.h>
using namespace std;
int szom[100001];
vector<int> g[100001]; 
int n,m,k;
bool seen[100001];
vector<int> ans;
int bfs(int x){
	queue<int> q;
	q.push(x);
	int cnt=0; 
	seen[x]=true; 
	if (szom[x]<k) return 0;
	ans.push_back(x);
	while (!q.empty()){
		int v=q.front();
		q.pop();
		for (int edge:g[v]){
			if (!seen[edge]){
				seen[edge]=true; 
				if (szom[edge]>=k){
					cnt++;
					ans.push_back(edge);
					q.push(edge);
				}
			}
		}
	}
	return cnt;

}
int main() {
	cin>>n>>m>>k;
	for (int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		szom[x]++;
		szom[y]++;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int mego=0; 
	vector<int> meg; 
	for (int i=1; i<=n;i++){
		if (!seen[i]){
			int z=bfs(i);
			if (z>mego){
				meg=ans;
				ans.clear();
				mego=z; 
			}
		}
	}
	sort(meg.begin(), meg.end());
	cout<<mego<<endl;
	for (int i:meg) cout<<i<<" "; 
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/04ms6596 KiB
2Wrong answer0/085ms11296 KiB
3Wrong answer0/24ms7072 KiB
4Wrong answer0/24ms7392 KiB
5Wrong answer0/24ms7620 KiB
6Wrong answer0/24ms7568 KiB
7Wrong answer0/24ms7824 KiB
8Wrong answer0/24ms7944 KiB
9Wrong answer0/24ms8172 KiB
10Wrong answer0/29ms8584 KiB
11Wrong answer0/24ms8516 KiB
12Wrong answer0/28ms8684 KiB
13Wrong answer0/34ms8744 KiB
14Wrong answer0/38ms9156 KiB
15Wrong answer0/310ms9580 KiB
16Wrong answer0/381ms12368 KiB
17Wrong answer0/39ms9184 KiB
18Wrong answer0/314ms9880 KiB
19Wrong answer0/390ms15492 KiB
20Wrong answer0/3151ms17008 KiB
21Wrong answer0/3100ms15672 KiB
22Wrong answer0/34ms9016 KiB