Submission #249025

# Submission time Handle Problem Language Result Execution time Memory
249025 2020-07-14T07:08:24 Z Vladikus004 Baza (COCI17_baza) C++14
50 / 50
137 ms 9080 KB
#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";
    }
}
# Verdict Execution time Memory 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