Source Code
#include <bits/stdc++.h> 
#define int long long
#define f first
#define s second
#define pb push_back
#define endl "\n"
#define SORT(v) sort(begin(v), end(v))
using namespace std;
int32_t main(){ ios::sync_with_stdio(false);cin.tie(0);
    int q,n;cin >> q >> n;
    int x; cin >> x;
    vector<int> v(n,0);
    vector<int> a(n,0);
    for(int i = 0;i<x;i++){
        int z;cin >> z;
        z--;
        v[z] = 1;
    }
    vector<vector<int>> p(q);
    for(int j = 0;j<q;j++){
        int b;cin >> b;
        bool d = true;
        for(int i = 0;i<b;i++){
            int student;cin >> student;
            p[j].pb(student-1);
            if(!v[student-1]) d = false;
        }
        if(d){
            for(int i = 0;i<b;i++){
                a[p[j][i]]++;
            }
        }
    }
    vector<int> ans;
    for(int j = 0;j<q;j++){
        bool d = true;
        int b = p[j].size();
        for(int i = 0;i<b;i++){
            if(!v[p[j][i]] or a[p[j][i]] != 1) d = false;
        }
        if(d){
            ans.pb(j+1);
        }
    }
    cout << ans.size() << endl;
    if(ans.size()) for(int i : ans) cout << i << " ";
}
Copy
Projects barakat
GNU G++17
513 ms
64.2 MB
Wrong Answer