Source Code
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <stack>
#include <map>
#include <math.h>
#include <cmath>
#include <string.h>
#include <numeric>
using namespace std;
typedef vector<int> vi ;
typedef long long ll;
#define all(x) (x).begin() , (x).end()
#define allR(x) (x).rbegin() , (x).rend()
#define pb push_back
const int N = 1e6+1, M=1e6+1, NN=1e8 , MX = 1e6+1;
const ll MXL=1e18 , MOD = 1e9 + 7 ;
int a[N];
bool  won[N];
int mp[N];
vector<vector<int>> v;
vector<int> pos, ans;
int main(){
    // freopen("input.txt", "r", stdin);
    int n, m, q;
    cin >> n>> m >> q;
    v.resize(n);
    while ( q-- ){
        int x;
        scanf("%d" , &x );
        won[x]=1;
    }
    for(int i=0 ; i<n ; i++ ){
        scanf("%d" , &q );
        int cnt=0;
        for(int j=0,x ; j<q ; j++ ){
            scanf("%d", &x );
            v[i].pb(x);
            if(won[x])
                cnt++;
        }
        if( cnt == q )
            pos.pb(i);
    }
    for(int i=0 ; i<pos.size() ; i++ ){
        int sz = v[pos[i]].size();
        for(int j=0 ; j<sz ; j++ ){
            int winner= v[pos[i]][j];
            mp[winner]++;
        }
    }
    for(int i=0 ; i<pos.size() ; i++ ){
        int cnt=0, sz=v[pos[i]].size();
        for(int j=0 ; j<sz ; j++ ){
            if(mp[  v[ pos[i] ] [j]   ] == 1 )
                cnt++;
        }
        if(cnt == sz )
            ans.pb(pos[i]+1);
    }
    sort(all(ans));
    printf("%d\n", ans.size() );
    for(auto i: ans)
        printf("%d ", i);
    return 0 ;
}
Copy
Projects Rand()
GNU G++17
341 ms
53.1 MB
Wrong Answer
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
341 ms
53.1 MB
Wrong Answer
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
636313
10 27 49 57 62 72 81 90 94 97 102 111 126 164 218 219 246 253 258 260 265 276 289 332 368 370 373 375 380 384 415 417 447 448 455 465 467 480 482 483 493 530 531 547 548 553 561 574 575 581 600 608 619 663 667 687 696 715 717 718 742 745 746 ...
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
The number of winning projects is 122 while the contestent is 636313