84732024-01-17 11:44:37GhostHálózati biztonság (50)cpp17Time limit exceeded 44/50328ms55636 KiB
#include <iostream>
#include <vector>
#include <set>
#include <stack>
#include <queue>

using namespace std;

int main()
{
    int n, m, k, i, temp1, temp2;
    cin >> n >> m >> k;

    vector<set<int>> map(n);
    for (i = 0; i < m; i++) {
        cin >> temp1 >> temp2;
        temp1--; temp2--;
        map[temp1].insert(temp2);
        map[temp2].insert(temp1);
    }

    queue<int> bad;
    for (i = 0; i < n; i++) {
        if (map[i].size() < k) {
            bad.push(i);
        }
    }

    while (!bad.empty()) {
        int node = bad.front();
        bad.pop();
        for (int v : map[node]) {
            map[v].erase(node);
            if (map[v].size() < k) {
                bad.push(v);
            }
        }
    }

    vector<int> out;
    for (i = 0; i < n; i++) {
        if (map[i].size() >= k) {
            out.push_back(i);
        }
    }
    cout << out.size() << endl;
    for (i = 0; i < out.size(); i++) {
        cout << out[i]+1 << " ";
    }
}
SubtaskSumTestVerdictTimeMemory
base44/50
1Accepted0/03ms1808 KiB
2Accepted0/0166ms27772 KiB
3Accepted2/23ms3524 KiB
4Accepted2/23ms3600 KiB
5Accepted2/23ms3724 KiB
6Accepted2/23ms3820 KiB
7Accepted2/23ms3944 KiB
8Accepted2/23ms4312 KiB
9Accepted2/23ms4220 KiB
10Accepted2/212ms6456 KiB
11Accepted2/24ms5224 KiB
12Accepted2/28ms6088 KiB
13Accepted3/33ms5264 KiB
14Accepted3/38ms7104 KiB
15Accepted3/39ms8560 KiB
16Time limit exceeded0/3319ms31656 KiB
17Accepted3/39ms8580 KiB
18Accepted3/316ms13972 KiB
19Accepted3/3172ms37288 KiB
20Time limit exceeded0/3328ms55636 KiB
21Accepted3/3180ms43368 KiB
22Accepted3/33ms11944 KiB