답안 #341719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341719 2020-12-30T15:52:52 Z alrad Baza (COCI17_baza) C++17
50 / 50
75 ms 7916 KB
#include <bits/stdc++.h>

using namespace std;

using ld = long double;

/*
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

template <class T> inline T gcd(T a , T b) { return !a ? b : gcd(b % a , a); }
template <class T> inline T lcm(T a , T b) {return (a * b) / gcd(a , b) ; }

mt19937 rnd(time(0));

#define all(x) x.begin(), x.end()
#define debug(x) { cerr << #x << " = " << x << endl; }

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> f(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> f[i][j];
    }
  }
  int q;
  cin >> q;
  while (q-- > 0) {
    vector<int> cnt(m);
    for (int i = 0; i < m; i++) {
      cin >> cnt[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      bool good = true;
      for (int j = 0; j < m && good; j++) {
        if (cnt[j] != -1 && (cnt[j] != f[i][j])) {
          good = false;
        }
      }
      ans += good;
    }
    cout << ans << '\n';
  }
  return;
}

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0) , cout.tie(0);
  int t = 1;
  while (t-- > 0) {
    solve();
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2668 KB Output is correct
2 Correct 16 ms 1900 KB Output is correct
3 Correct 47 ms 5228 KB Output is correct
4 Correct 12 ms 1516 KB Output is correct
5 Correct 37 ms 4076 KB Output is correct
6 Correct 56 ms 5996 KB Output is correct
7 Correct 75 ms 7916 KB Output is correct
8 Correct 46 ms 5100 KB Output is correct
9 Correct 28 ms 3308 KB Output is correct
10 Correct 72 ms 7788 KB Output is correct