87582024-01-29 11:04:21GervidHálózati biztonság (50)cpp17Elfogadva 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 << ' ';
	}
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1816 KiB
2Elfogadva0/086ms14460 KiB
3Elfogadva2/23ms3252 KiB
4Elfogadva2/23ms3468 KiB
5Elfogadva2/23ms3568 KiB
6Elfogadva2/23ms3844 KiB
7Elfogadva2/23ms3772 KiB
8Elfogadva2/23ms4000 KiB
9Elfogadva2/23ms4492 KiB
10Elfogadva2/28ms4660 KiB
11Elfogadva2/23ms4496 KiB
12Elfogadva2/26ms4872 KiB
13Elfogadva3/33ms4748 KiB
14Elfogadva3/37ms5428 KiB
15Elfogadva3/38ms5984 KiB
16Elfogadva3/382ms13160 KiB
17Elfogadva3/38ms5764 KiB
18Elfogadva3/312ms8572 KiB
19Elfogadva3/392ms20216 KiB
20Elfogadva3/3160ms26592 KiB
21Elfogadva3/3101ms20620 KiB
22Elfogadva3/33ms5424 KiB