22542023-01-06 10:10:571478Hálózati biztonság (50)cpp11Accepted 50/50149ms15848 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

int main()
{
    //ifstream cin("be.txt");
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> nb(n + 1);
    for (int i = 1; i <= m; i++)
    {
        int a, b;
        cin >> a >> b;
        nb[a].push_back(b);
        nb[b].push_back(a);
    }

    vector<bool> active(n + 1, 1);
    bool change = 1;
    int ans = n;
    while (change)
    {
        change = 0;
        for (int i = 1; i <= n; i++)
        {
            if (active[i])
            {
                int db = 0;
                for (int j = 0; j < nb[i].size(); j++)
                {
                    if (active[nb[i][j]])
                    {
                        db++;
                    }
                }
                if (db < k)
                {
                    active[i] = 0;
                    ans--;
                    change = 1;
                }
            }
        }
    }

    cout<<ans<<'\n';
    for (int i = 1; i <= n; i++)
    {
        if(active[i]){
            cout << i << " ";
        }

    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/081ms8208 KiB
3Accepted2/22ms2284 KiB
4Accepted2/22ms2364 KiB
5Accepted2/22ms2404 KiB
6Accepted2/22ms2468 KiB
7Accepted2/22ms2524 KiB
8Accepted2/22ms2732 KiB
9Accepted2/22ms2932 KiB
10Accepted2/28ms3560 KiB
11Accepted2/23ms3276 KiB
12Accepted2/26ms3804 KiB
13Accepted3/33ms3540 KiB
14Accepted3/36ms4108 KiB
15Accepted3/38ms4956 KiB
16Accepted3/378ms8200 KiB
17Accepted3/37ms4180 KiB
18Accepted3/310ms6388 KiB
19Accepted3/390ms14056 KiB
20Accepted3/3149ms15848 KiB
21Accepted3/394ms14596 KiB
22Accepted3/32ms4228 KiB