9962022-02-20 07:36:50Szin AttilaHálózati biztonság (50)cpp14Wrong answer 37/50175ms19692 KiB
#include <bits/stdc++.h>
using namespace std;

int n,m,k;
vector<vector<int> > g;
vector<int> mo;
vector<bool> volt;
set<int> curr;

bool dfs(int x) {

    int cnt = 0;
    curr.insert(x);
    for(int sz : g[x]) {
        if(!volt[sz] && g[sz].size() >= k) {
            volt[sz] = true;
            if(dfs(sz)) {
                cnt++;
            }
        }
        else if(curr.find(sz) != curr.end()) cnt++;
    }
    if(cnt < k) {
        curr.erase(x);
        return false;
    }
    return true;
}

int main()
{
    cin >> n >> m >> k;
    g.resize(n+1);
    volt.resize(n+1, false);

    for(int i = 0; i < m; i++) {
        int x,y;
        cin >> x >> y;

        g[x].push_back(y);
        g[y].push_back(x);
    }

    for(int i = 1; i <= n; i++) {
        if(g[i].size() >= k && !volt[i]) {
            curr.clear();
            volt[i] = true;
            if(dfs(i) && curr.size() > mo.size()) {
                mo.clear();
                for(int j : curr) mo.push_back(j);
            }
        }
    }
    sort(mo.begin(), mo.end());
    cout << mo.size() << endl;
    for(int i : mo) cout << i << ' ';

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base37/50
1Accepted0/02ms1740 KiB
2Accepted0/083ms9032 KiB
3Accepted2/21ms2976 KiB
4Wrong answer0/21ms2972 KiB
5Accepted2/21ms2988 KiB
6Wrong answer0/21ms2984 KiB
7Accepted2/21ms2984 KiB
8Accepted2/22ms3008 KiB
9Accepted2/21ms3016 KiB
10Accepted2/28ms3588 KiB
11Accepted2/22ms3152 KiB
12Accepted2/24ms3476 KiB
13Accepted3/32ms3252 KiB
14Accepted3/34ms3916 KiB
15Accepted3/37ms4624 KiB
16Wrong answer0/383ms9472 KiB
17Wrong answer0/36ms5176 KiB
18Accepted3/39ms7488 KiB
19Accepted3/397ms15948 KiB
20Wrong answer0/3175ms19692 KiB
21Accepted3/3109ms19496 KiB
22Accepted3/31ms9096 KiB