Submission #168088

# Submission time Handle Problem Language Result Execution time Memory
168088 2019-12-11T10:42:34 Z sans Baza (COCI17_baza) C++14
50 / 50
88 ms 7928 KB
#include <iostream>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

vector<vector<int>> grid;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int N, M; cin >> N >> M;
    grid.resize(N, vector<int>(M));
    for(int i = 0; i < N; ++i)
        for(int j = 0; j < M; ++j)
            cin >> grid[i][j];

    int Q; cin >> Q;
    while(Q--){
        vector<pair<int, int>> p;
        int ans = 0;
        for(int i = 0; i < M; ++i){ int q; cin >> q; if(q != -1) p.pb(mp(i, q)); }
        for(int i = 0; i < N; ++i){
            bool uygun = true;
            for(int j = 0; j < (int)p.size(); ++j){
                if(grid[i][p[j].st] != p[j].nd){ uygun = false; break; }
            }
            if(uygun) ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

//cikisir
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2680 KB Output is correct
2 Correct 19 ms 1912 KB Output is correct
3 Correct 56 ms 5240 KB Output is correct
4 Correct 15 ms 1528 KB Output is correct
5 Correct 43 ms 4088 KB Output is correct
6 Correct 64 ms 6008 KB Output is correct
7 Correct 85 ms 7928 KB Output is correct
8 Correct 55 ms 5164 KB Output is correct
9 Correct 34 ms 3320 KB Output is correct
10 Correct 88 ms 7792 KB Output is correct