151282025-02-13 11:00:03BencuHálózati biztonság (50)cpp17Time limit exceeded 38/50400ms6964 KiB
#include <bits/stdc++.h>

using namespace std;
int n,m,k,ma,M[100001];
struct Bencu{
    vector<int>szom;
    int fok;
    int csucs;
} L[100001];
int main()
{
    //ifstream f("be.in");
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m>>k;
    for (int i=1; i<=m; i++) {
        int x,y;
        cin>>x>>y;
        L[x].szom.push_back(y);
        L[x].fok++;
        L[x].csucs++;
        L[y].szom.push_back(x);
        L[y].fok++;
        L[y].csucs++;
    }
    for (int i=1; i<=n; i++) {
        if (L[i].fok<k && L[i].fok>0) {
            for (int j=0; j<L[i].csucs; j++) {
                L[L[i].szom[j]].fok--;
            }
            L[i].fok=0;
            i=0;
        }
    }
    for (int i=1; i<=n; i++) {
        if (L[i].fok>0) {
            M[ma]=i;
            ma++;
        }
    }
    cout<<ma<<endl;
    for (int i=0; i<ma; i++) cout<<M[i]<<" ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base38/50
1Accepted0/04ms3572 KiB
2Time limit exceeded0/0372ms5424 KiB
3Accepted2/23ms3380 KiB
4Accepted2/23ms3380 KiB
5Accepted2/24ms3380 KiB
6Accepted2/23ms3380 KiB
7Accepted2/23ms3380 KiB
8Accepted2/24ms3380 KiB
9Accepted2/23ms3380 KiB
10Accepted2/26ms3664 KiB
11Accepted2/24ms3380 KiB
12Accepted2/27ms3664 KiB
13Accepted3/34ms3380 KiB
14Accepted3/337ms3756 KiB
15Accepted3/390ms3848 KiB
16Time limit exceeded0/3400ms5032 KiB
17Accepted3/332ms3636 KiB
18Accepted3/3195ms3892 KiB
19Time limit exceeded0/3381ms6196 KiB
20Time limit exceeded0/3386ms6964 KiB
21Time limit exceeded0/3400ms6452 KiB
22Accepted3/33ms3572 KiB