#include <bits/stdc++.h>
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
const int N = 1000 + 3;
int n, m, a[N][N], q, b[N];
int can(int ind){
int ans = 1;
for (int i = 0; i < m; i++){
if (b[i] != -1 && a[ind][i] != b[i]) ans = 0;
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif // LOCAL
cin >> n >> m;
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
cin >> a[i][j];
}
}
cin >> q;
while (q--){
for (int i = 0; i < m; i++) cin >> b[i];
int ans = 0;
for (int i = 0; i < n; i++) ans += can(i);
cout << ans << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
2936 KB |
Output is correct |
2 |
Correct |
22 ms |
2688 KB |
Output is correct |
3 |
Correct |
89 ms |
7160 KB |
Output is correct |
4 |
Correct |
18 ms |
2432 KB |
Output is correct |
5 |
Correct |
53 ms |
4344 KB |
Output is correct |
6 |
Correct |
97 ms |
6756 KB |
Output is correct |
7 |
Correct |
137 ms |
9080 KB |
Output is correct |
8 |
Correct |
75 ms |
5624 KB |
Output is correct |
9 |
Correct |
48 ms |
5624 KB |
Output is correct |
10 |
Correct |
123 ms |
7928 KB |
Output is correct |