#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int L[1003][1003];
int L2[1003];
int main(){
int N,M,x,y,Q,rj[53],zb,uk=0;
cin >> N >> M;
for (int i=0;i<N;i++){
for (int j=0;j<M;j++){
cin >> x;
L[i][j]=x;
}
}
cin >> Q;
for (int i=0;i<Q;i++){
zb=0;
for (int j=0;j<M;j++){
cin >> y;
L2[j]=y;
}
if (count(L2,L2+M,-1)!=M){
for (int i2=0;i2<N;i2++){
for (int j2=0;j2<M;j2++){
y=L2[j2];
if (y==-1){
continue;
}
if (y!=L[i2][j2]){
zb=0;
break;
}
zb+=1;
}
if (zb>0) uk+=1;
zb=0;
}
rj[i]=uk;
uk=0;
}
else rj[i]=N;
}
for (int i=0;i<Q;i++) cout << rj[i] << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
131 ms |
2936 KB |
Output is correct |
2 |
Correct |
91 ms |
2808 KB |
Output is correct |
3 |
Correct |
273 ms |
7268 KB |
Output is correct |
4 |
Correct |
68 ms |
2664 KB |
Output is correct |
5 |
Correct |
201 ms |
4344 KB |
Output is correct |
6 |
Correct |
303 ms |
6648 KB |
Output is correct |
7 |
Correct |
405 ms |
9220 KB |
Output is correct |
8 |
Correct |
253 ms |
5628 KB |
Output is correct |
9 |
Correct |
163 ms |
5500 KB |
Output is correct |
10 |
Correct |
413 ms |
8156 KB |
Output is correct |