87582024-01-29 11:04:21GervidHálózati biztonság (50)cpp17Accepted 50/50160ms26592 KiB
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <limits.h>
#include <map>
#include <stack>
#include <algorithm>

using namespace std;

void deledges(vector<vector<int>>& g, vector<int>& degree, int node, int k)
{
	degree[node] = -1;
	for (int i = 0; i < g[node].size(); i++)
	{
		if (--degree[g[node][i]] < k && degree[g[node][i]] > 0)
		{
			deledges(g, degree, g[node][i], k);
		}
	}
}

int main()
{
	int n, m, k, i, node1, node2;
	cin >> n >> m >> k;

	vector<vector<int>> g(n);
	vector<int> degree(n, 0);

	for (i = 0; i < m; i++)
	{
		cin >> node1 >> node2;
		node1--, node2--;

		g[node1].push_back(node2);
		g[node2].push_back(node1);

		degree[node1]++;
		degree[node2]++;
	}

	bool done = false;
	node1 = 0;

	for (i = 0; i < n; i++)
	{
		if (degree[i] < k && degree[i] > 0)
		{
			deledges(g, degree, i, k);
		}
	}

	vector<int> out;
	out.reserve(n);

	for (i = 0; i < n; i++)
	{
		if (degree[i] >= k)
		{
			out.push_back(i);
		}
	}

	cout << out.size() << '\n';

	for (i = 0; i < out.size(); i++)
	{
		cout << out[i] + 1 << ' ';
	}
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1816 KiB
2Accepted0/086ms14460 KiB
3Accepted2/23ms3252 KiB
4Accepted2/23ms3468 KiB
5Accepted2/23ms3568 KiB
6Accepted2/23ms3844 KiB
7Accepted2/23ms3772 KiB
8Accepted2/23ms4000 KiB
9Accepted2/23ms4492 KiB
10Accepted2/28ms4660 KiB
11Accepted2/23ms4496 KiB
12Accepted2/26ms4872 KiB
13Accepted3/33ms4748 KiB
14Accepted3/37ms5428 KiB
15Accepted3/38ms5984 KiB
16Accepted3/382ms13160 KiB
17Accepted3/38ms5764 KiB
18Accepted3/312ms8572 KiB
19Accepted3/392ms20216 KiB
20Accepted3/3160ms26592 KiB
21Accepted3/3101ms20620 KiB
22Accepted3/33ms5424 KiB