-
-
Save enzerr/6617faaca9d8da9bc444f21affcf6241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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