#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
const int N = 1e3+5;
int n,m,a[N][N],b[N],q,ans;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>a[i][j];
cin>>q;
while(q--){
for(int i=1;i<=m;i++){
cin>>b[i];
}
ans=0;
for(int i=1;i<=n;i++){
bool ok=true;
for(int j=1;j<=m;j++){
if(b[j]==-1)continue;
if(b[j]!=a[i][j])ok=false;
}
if(ok)ans++;
}
cout<<ans<<"\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
2936 KB |
Output is correct |
2 |
Correct |
24 ms |
4488 KB |
Output is correct |
3 |
Correct |
89 ms |
10024 KB |
Output is correct |
4 |
Correct |
21 ms |
10024 KB |
Output is correct |
5 |
Correct |
58 ms |
10852 KB |
Output is correct |
6 |
Correct |
97 ms |
15756 KB |
Output is correct |
7 |
Correct |
141 ms |
21660 KB |
Output is correct |
8 |
Correct |
75 ms |
23164 KB |
Output is correct |
9 |
Correct |
49 ms |
26164 KB |
Output is correct |
10 |
Correct |
120 ms |
30344 KB |
Output is correct |