Skip to content

Instantly share code, notes, and snippets.

@enzerr
Created June 14, 2023 13:34
Show Gist options
  • Save enzerr/6617faaca9d8da9bc444f21affcf6241 to your computer and use it in GitHub Desktop.
Save enzerr/6617faaca9d8da9bc444f21affcf6241 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
bool mtx[maxn][maxn];
int c[maxn];
int main(){
int n, m; cin >> n >> m;
for(int i = 0; i < m; i++){
int a, b; cin >> a >> b;
mtx[a][b] = mtx[b][a] = 1;
}
int ans = 0;
int p; cin >> p;
for(int i = 0; i < p; i++){
int k; cin >> k;
for(int i = 0; i < k; i++) cin >> c[i];
bool ok = true;
for(int i = 1; i < k; i++) if(mtx[c[i]][c[i-1]] == 0) ok = false;
if(ok) ans++;
}
cout << ans << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment