Problem p02911 (C++)

Buggy submission (status: Runtime Error):
/*
 * Author : Sadi
 * Thu 09/07/2020
 * 21:53:16.66
 */
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define watch(x)                                                               \
  ;                                                                            \
  cout << "\n" << #x << " is: " << x << "\n";
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

template <class A, class B>
ostream &operator<<(ostream &output, const pair<A, B> &p) {
  output << "(" << p.first << ", " << p.second << ")";
  return output;
}

template <class A> ostream &operator<<(ostream &output, const vector<A> &a) {
  output << "[";
  for (auto it = a.begin(); it != a.end(); ++it) {
    if (it != a.begin()) {
      output << ", ";
    }
    output << *it;
  }
  output << "]";
  return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

// const int inf = 1e9;
// const int mod = 1e9 + 7;
// const double PI = acos(-1.0);
// const int mx = 1e5 + 5;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

  int n, k, q;
  cin >> n >> k >> q;
  vector<int> v(q);
  unordered_map<int, int> umap;
  for (int i = 1; i <= q; ++i) {
    cin >> v[i];
    umap[v[i]]++;
  }
  for (int i = 1; i <= n; ++i) {
    int not_answered = q - umap[i];
    if (k - not_answered <= 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}


Fixed submission:
/*
 * Author : Sadi
 * Thu 09/07/2020
 * 21:53:16.66
 */
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define watch(x)                                                               \
  ;                                                                            \
  cout << "\n" << #x << " is: " << x << "\n";
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

template <class A, class B>
ostream &operator<<(ostream &output, const pair<A, B> &p) {
  output << "(" << p.first << ", " << p.second << ")";
  return output;
}

template <class A> ostream &operator<<(ostream &output, const vector<A> &a) {
  output << "[";
  for (auto it = a.begin(); it != a.end(); ++it) {
    if (it != a.begin()) {
      output << ", ";
    }
    output << *it;
  }
  output << "]";
  return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

// const int inf = 1e9;
// const int mod = 1e9 + 7;
// const double PI = acos(-1.0);
// const int mx = 1e5 + 5;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

  int n, k, q;
  cin >> n >> k >> q;
  vector<int> v(q + 1);
  unordered_map<int, int> umap;
  for (int i = 1; i <= q; ++i) {
    cin >> v[i];
    umap[v[i]]++;
  }
  for (int i = 1; i <= n; ++i) {
    int not_answered = q - umap[i];
    if (k - not_answered <= 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}