91102024-02-14 12:30:18RRoliHálózati biztonság (50)cpp17Time limit exceeded 35/50400ms6548 KiB
#include <iostream>

using namespace std;

struct{
    int p1; int p2;
} a[200001];
int n, m, k, sz[100001], vsor[100001], utolso;

int main()
{
    cin >> n >> m >> k;

    for(int i = 1; i <= m; i++) {
        cin >> a[i].p1 >> a[i].p2;
        sz[a[i].p1]++;
        sz[a[i].p2]++;
    }

    for(int i = 1; i <= n; i++) {
        if(sz[i] < k) {
            sz[i] = -1;
            utolso++;
            vsor[utolso] = i;
        }
    }

    int elso = 1;
    while(elso <= utolso) {
        int t = vsor[elso];
        for(int i = 1; i <= m; i++) {
            if(a[i].p1 == t && sz[a[i].p2] != -1) {
                sz[a[i].p2]--;
                if(sz[a[i].p2] < k) {
                    sz[a[i].p2] = -1;
                    utolso++;
                    vsor[utolso] = a[i].p2;
                }
            }
            if(a[i].p2 == t && sz[a[i].p1] != -1) {
                sz[a[i].p1]--;
                if(sz[a[i].p1] < k) {
                    sz[a[i].p1] = -1;
                    utolso++;
                    vsor[utolso] = a[i].p1;
                }
            }
        }
        elso++;
    }

    cout << n - utolso << endl;
    for(int i = 1; i <= n; i++)
        if(sz[i] != -1)
            cout << i << ' ';


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/50
1Accepted0/03ms2040 KiB
2Time limit exceeded0/0400ms3632 KiB
3Accepted2/23ms3460 KiB
4Accepted2/23ms3660 KiB
5Accepted2/23ms3880 KiB
6Accepted2/23ms4092 KiB
7Accepted2/23ms4224 KiB
8Accepted2/23ms4312 KiB
9Accepted2/23ms4308 KiB
10Accepted2/28ms4524 KiB
11Accepted2/28ms4416 KiB
12Accepted2/239ms4600 KiB
13Accepted3/37ms4488 KiB
14Accepted3/3105ms4716 KiB
15Accepted3/3270ms5252 KiB
16Time limit exceeded0/3370ms5144 KiB
17Accepted3/3101ms5316 KiB
18Time limit exceeded0/3367ms4752 KiB
19Time limit exceeded0/3352ms6048 KiB
20Time limit exceeded0/3356ms6548 KiB
21Time limit exceeded0/3361ms5920 KiB
22Accepted3/33ms5044 KiB