Source Code
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define pb push_back

int main(){
    int n, m;
    scanf("%d%d", &n, &m);

    vector<pair<int,vector<int>>> v;
    map<int,bool> won;

    int par;
    scanf("%d", &par);
    while ( par-- ){
        int x;
        scanf("%d", &x);
        won[x]=1;
    }

    map<int, int> mp;
    v.resize(n);
    for(int i=0 ; i<n ; i++){
        int q, x;
        scanf("%d", &q);
        vector<int> team;
        team.resize(q);
        bool flag=0;
        for(int i=0; i<q ; i++){
            scanf("%d", &x);
            if(!won[x])
                flag=1;
            team.pb(x);
        }
        if(!flag){
            v.pb({i+1, team});
            for( auto k : team )
                mp[k]++;
        }
    }

    vector<int> ans;
    for(int i=0 ; i<v.size() ; i++){
        for(auto j: v[i].second ){
            if(mp[j]==1){
                ans.pb(v[i].first);
                break;
            }
        }
    }

    printf("%d\n", ans.size() );
    for(auto i: ans)
        printf("%d ", i);
    puts("");
    
    return 0 ;
} 
Copy
Projects Rand()
GNU G++17
2104 ms
81.8 MB
Time Limit Exceeded
Test Case #1
1 ms
360 KB
Accepted
Input
3 3
2 1 2
3 1 2 3
2 1 2
2 2 3
Output
1
2
Judge Output
1
2
Checker Message
The contestent found 1 winning projects
Test Case #2
0 ms
396 KB
Accepted
Input
4 3
3 1 2 3
2 1 2
2 2 3
2 1 3
3 1 2 3
Output
0
Judge Output
0
Checker Message
The contestent found 0 winning projects
Test Case #3
2104 ms
81.8 MB
Time Limit Exceeded
Input
1000000 200000
200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79...
Output

Judge Output
122
12269 14079 15963 18354 23640 24075 29268 31842 32984 35362 41572 43463 45675 53188 54545 55900 59406 72225 73621 74584 75921 79748 81592 86962 87758 94995 96767 97532 101145 102180 104453 113082 114567 118886 119947 122336 125108 127214 132550 ...
Checker Message