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, M=1e6+1, NN=1e8 , MX = 1e6+1;
const ll MXL=1e18 , MOD = 1e9 + 7 ;
int a[N];
map<int, bool> won;
map<int,int> mp;
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.count(v[pos[i]][j]) && mp[  v[ pos[i] ] [j]  ] == 1 ){
                cnt++;
                break;
            }
        }
        if(cnt)
            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
2102 ms
63.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
392 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
2102 ms
63.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