9932022-02-20 07:31:15Szin AttilaHálózati biztonság (50)cpp14Wrong answer 46/50207ms19684 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;
            dfs(i);
            if(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
base46/50
1Accepted0/02ms1776 KiB
2Accepted0/082ms9004 KiB
3Accepted2/22ms2980 KiB
4Wrong answer0/21ms2988 KiB
5Accepted2/21ms3000 KiB
6Wrong answer0/21ms2996 KiB
7Accepted2/21ms3004 KiB
8Accepted2/21ms3016 KiB
9Accepted2/21ms3016 KiB
10Accepted2/28ms3632 KiB
11Accepted2/22ms3160 KiB
12Accepted2/24ms3416 KiB
13Accepted3/32ms3260 KiB
14Accepted3/36ms4016 KiB
15Accepted3/36ms4584 KiB
16Accepted3/386ms9452 KiB
17Accepted3/36ms5124 KiB
18Accepted3/39ms7400 KiB
19Accepted3/3101ms15952 KiB
20Accepted3/3207ms19684 KiB
21Accepted3/3100ms19444 KiB
22Accepted3/31ms9116 KiB