96252024-02-23 15:21:06zeytonxHálózati biztonság (50)cpp17Accepted 50/5086ms24256 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef vector<vll> v2ll;
typedef map<ll,ll> mll;
typedef vector<pll> vpll;
typedef map<pll,ll> mpll;
#define fs first
#define sc second
#define pb push_back

const ll MOD = 1e9+7;



void solve()
{
    ll n, m, k;
    cin >> n >> m >> k;
    v2ll g(n);
    vll rc(n, 0);
    for(ll i = 0; i < m; i++)
    {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].pb(b);
        g[b].pb(a);
    }

    qll q;
    vll used(n, 0);
    for(ll i = 0; i < n; i++)
    {
        rc[i] = g[i].size();
        if(rc[i] < k)
        {
            q.push(i);
            used[i] = 1;
        }
    }

    while(!q.empty())
    {
        ll p = q.front();
        used[p] = 2;
        q.pop();
        for(ll i : g[p])
        {
            if(used[i] != 2)
            {
                if(rc[i] >= k)
                    rc[i]--;
                if(rc[i] < k && used[i] == 0)
                {
                    q.push(i);
                    used[i] = 1;
                }
            }
        }
    }

    sll ans;
    for(ll i = 0; i < n; i++)
        if(rc[i] >= k)
            ans.insert(i);
    
    cout << ans.size() << "\n";
    for(ll i : ans)
        cout << i+1 << " ";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--)
        solve();
    cout << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1824 KiB
2Accepted0/046ms12880 KiB
3Accepted2/23ms2392 KiB
4Accepted2/23ms2604 KiB
5Accepted2/23ms2924 KiB
6Accepted2/23ms2868 KiB
7Accepted2/23ms3012 KiB
8Accepted2/23ms2992 KiB
9Accepted2/23ms3108 KiB
10Accepted2/26ms3912 KiB
11Accepted2/23ms3540 KiB
12Accepted2/24ms4100 KiB
13Accepted3/33ms3812 KiB
14Accepted3/34ms4640 KiB
15Accepted3/37ms5804 KiB
16Accepted3/346ms11652 KiB
17Accepted3/36ms4360 KiB
18Accepted3/39ms9056 KiB
19Accepted3/354ms20068 KiB
20Accepted3/386ms24256 KiB
21Accepted3/354ms20956 KiB
22Accepted3/33ms4160 KiB