Source Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 

int const N = 1e6+100;
int n, m, q, v[N], a[N], W[N];

int main(){
    scanf("%d%d%d", &n, &m, &q);
    for(int i = 0, c; i<q; ++i){
       scanf("%d", &c);
       v[c] = 1;
    }
    vector<int> an; 
    for(int i = 0, x; i<n; ++i){
       scanf("%d", &x);
       int c = 0;
       for(int j = 0; j<x; ++j){
         scanf("%d", &a[j]);
         if(v[a[j]])++c;
     }
     if(c == x){
     	for(int j = 0; j<x; ++j)v[a[j]] = 0;
     	an.push_back(i+1);
     }
    }
    for(int i = 1; i<N; ++i)if(v[i])an.clear();
    cout << an.size() << "\n";
    for(auto i: an)cout << i << "\n"; 
}
Copy
Projects molukhyyeh
GNU G++17
290 ms
5.4 MB
Wrong Answer