161532025-04-07 07:36:17BencuKritikus munkákcpp17Runtime error 25/100389ms32768 KiB
#include <bits/stdc++.h>

using namespace std;
int n,m,s,a[5001][5001],L[5001];

struct Bencu {
    int x;
    int y;
}b[50001];

/*struct Bencu {
    vector<int>munka;
}a[100001];*/

int main()
{
    ifstream f("be.in");
    cin>>n>>m;
    for (int i=1; i<=m; i++) {
        int x,y;
        cin>>x>>y;
        b[i].x=x;
        b[i].y=y;
        //a[y].munka.push_back(x);
        a[x][y]=1;
        for (int i=1; i<=n; i++) {
            if (a[i][x]==1) a[i][y]=1;
            if (a[y][i]==1) a[x][i]=1;
        }
    }
    for (int i=1; i<=n; i++) {
        int sz=1;
        for (int j=1; j<=m; j++) {
            int x=b[j].x,y=b[j].y;
            if (x!=i && y!=i && a[i][x]==0 && a[y][i]==0) {
                sz=0;
                break;
            }
        }
        if (sz==1) {
            s++;
            L[s]=i;
        }
    }
    cout<<s<<endl;
    for (int i=1; i<=s; i++) cout<<L[i]<<" ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Runtime error1ms316 KiB
subtask225/25
3Accepted1ms564 KiB
4Accepted3ms1588 KiB
5Accepted18ms6968 KiB
6Accepted2ms820 KiB
7Accepted28ms6968 KiB
subtask30/25
8Time limit exceeded388ms10880 KiB
9Time limit exceeded389ms27952 KiB
10Runtime error223ms32768 KiB
11Time limit exceeded388ms23984 KiB
12Time limit exceeded381ms19764 KiB
subtask40/25
13Runtime error1ms564 KiB
14Runtime error1ms564 KiB
15Runtime error1ms564 KiB
16Runtime error1ms508 KiB
17Runtime error1ms316 KiB
subtask50/25
18Runtime error1ms316 KiB
19Runtime error1ms316 KiB
20Runtime error1ms316 KiB
21Runtime error1ms508 KiB
22Runtime error1ms316 KiB