alexjercan/bugnet huggingface dataset:
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

int N, K;
vector<int> d;
vector<vector<int>> A;

void input() {
  cin >> N >> K;
  d.resize(K);
  A.resize(K, vector<int>());
  for (int i = 0; i < K; i++) {
    cin >> d.at(i);
    A.at(i).resize(d.at(i));
    for (int j = 0; j < d.at(i); j++) {
      cin >> A.at(i).at(j);
    }
  }
}

void solve() {
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    bool have = false;
    for (auto v : A) {
      for (auto p : v) {
        if (p == i)
          have = true;
      }
    }
    if (!have)
      ans++;
  }
  cout << ans << endl;
}

int main() {
  input();
  solve();
  return 0;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 8) >= this->size() (which is 6)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K, tmp, cnt;
  cin >> N >> K;

  vector<int> d(K * N);

  for (int i = 0; i < K; i++) {
    cin >> tmp;
    for (int j = 0; j < tmp; j++) {
      cin >> d.at(cnt);
      cnt++;
    }
  }

  sort(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()), d.end());

  cout << N - d.size() + 1 << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K, d, a;
  cin >> N >> K;
  vector<bool> ans2(N, true);
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> a;
      a--;
      ans2[a] = false;
    }
  }
  int ans1 = 0;
  for (int i = 0; i < N; i++) {
    if (ans2[i] == true)
      ans1++;
  }

  cout << ans1 << endl;
}


Error: -6
double free or corruption (out)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> num(110);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      vector<int> A(110);
      for (int k = 0; k < d; k++)
        cin >> A[k];
      num[A[j] - 1]++;
    }
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (num[i] > 0)
      sum++;
  }
  cout << N - sum << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;

  vector<vector<int>> vec(K, vector<int>(N, 0));

  // おかしを持っているかどうかに印を付ける//
  for (int i = 0; i < K; i++) {
    int T; // Tは持ってる人間の数、i番目のおかしの数//
    cin >> T;
    for (int j = 0; j < T; j++) {
      int f; // fが持ってる人間の番号//
      cin >> f;
      vec.at(i).at(f - 1) = 1; // 持っている人間を1と置く(持っている判定にする)//
    }
  }
  // 作成した表を用いて持っていない人間を判定する//
  int count = 0;
  for (int i = 0; i < N; i++) { // N人について、１番から順に確かめる//
    for (int j = 0; j < K; j++) {
      if (vec.at(j).at(i) == 1) {
        break;
      } else if (j == K - 1 && vec.at(j).at(i) == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;

  vector<vector<int>> vec(K, vector<int>(N, 0));

  // おかしを持っているかどうかに印を付ける//
  for (int i = 0; i < K; i++) {
    int T; // Tは持ってる人間の数、i番目のおかしの数//
    cin >> T;
    for (int j = 0; j < T; j++) {
      int f; // fが持ってる人間の番号//
      cin >> f;
      vec.at(i).at(f - 1) = 1; // 持っている人間を1と置く(持っている判定にする)//
    }
  }
  // 作成した表を用いて持っていない人間を判定する//
  int count = 0;
  for (int i = 0; i < N; i++) { // N人について、１番から順に確かめる//
    for (int j = 0; j < K; j++) {
      if (vec.at(j).at(i) == 1) {
        break;
      } else if (j = K - 1 && vec.at(j).at(i) == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int index = 0;

  int arr[10000];
  while (k--) {
    int s;

    cin >> s;
    for (int i = 0; i < s; i++) {
      cin >> arr[index];
      index++;
    }
  }
  sort(arr, arr + index);

  int count = 1;
  for (int i = 1; i < index; i++) {
    if (arr[i] != arr[i - 1])
      count++;
  }
  cout << n - count;
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int index = 0;
  int p = k * (k + 1) / 2;
  int arr[p];
  while (k--) {
    int s;

    cin >> s;
    for (int i = 0; i < s; i++) {
      cin >> arr[index];
      index++;
    }
  }
  sort(arr, arr + index);

  int count = 1;
  for (int i = 1; i < index; i++) {
    if (arr[i] != arr[i - 1])
      count++;
  }
  cout << n - count;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int h[N];
  map<int, int> list;
  for (int i = 1; i <= N; i++)
    list[i] = 0;

  for (int i = 0; i < K; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int b;
      cin >> b;
      list[b]++;
    }
  }
  int cnt = 0;
  for (auto x : list) {
    if (x.second == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int h[N];
  int o[K];
  map<int, int> list;
  for (int i = 1; i <= N; i++)
    list[i] = 0;

  for (int i = 0; i < K; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      cin >> o[j];
      list[o[j]]++;
    }
  }
  int cnt = 0;
  for (auto x : list) {
    if (x.second == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (i = 0; i < n; i++)
#define rep1(i, n) for (i = 1; i <= n; i++)
#define test(a) cout << "*" << a << endl
#define ll long long
int main() {
  int n, k;
  int d[101];
  int A[101][101];
  int i, j;
  bool human[101] = {false};
  int humanNo = 0;

  cin >> n >> k;
  rep1(i, k) {
    cin >> d[i];
    rep1(j, d[i]) {
      cin >> A[i][j];
      human[A[i][j]] = true;
    }
  }
  rep1(i, n) {
    if (human[i] == false) {
      humanNo++;
      // test(i);
    }
  }
  cout << humanNo << endl;

  /*rep1(i,k){
    test(d[i]);
    rep1(j,d[i]){
      test(A[i][j]);
    }
  }*/
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (i = 0; i < n; i++)
#define rep1(i, n) for (i = 1; i <= n; i++)
#define test(a) cout << "*" << a << endl
#define ll long long
int main() {
  int n, k;
  int d[100];
  int A[100][100];
  int i, j;
  bool human[101] = {false};
  int humanNo = 0;

  cin >> n >> k;
  rep1(i, k) {
    cin >> d[i];
    rep1(j, d[i]) {
      cin >> A[i][j];
      human[A[i][j]] = true;
    }
  }
  rep1(i, n) {
    if (human[i] == false) {
      humanNo++;
      // test(i);
    }
  }
  cout << humanNo << endl;

  /*rep1(i,k){
    test(d[i]);
    rep1(j,d[i]){
      test(A[i][j]);
    }
  }*/
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, k;

  cin >> n >> k;

  vector<int> children(n);
  for (int i = 0; i < n; i++) {
    children[i] = 0;
  }

  for (int i = 0; i < k; i++) {
    int count;
    cin >> count;
    for (int j = 0; j < count; j++) {
      int index;
      cin >> index;
      children[index - 1] += 1;
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (children[i] == 0) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, k;

  cin >> n >> k;

  vector<int> children(n);
  for (int i = 1; i <= n; i++) {
    children[i] = 0;
  }

  for (int i = 0; i < k; i++) {
    int count;
    cin >> count;
    for (int j = 0; j < count; j++) {
      int index;
      cin >> index;
      children[index] += 1;
    }
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (children[i] == 0) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K, x = 0;
  cin >> N >> K;
  vector<vector<int>> sunuke(N, vector<int>(0));
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      sunuke.at(A - 1).push_back(i);
    }
  }
  for (int i = 0; i < N; i++) {
    if (sunuke.at(i).size() == 0)
      x++;
  }
  cout << x << endl;
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K, x = 0;
  cin >> N >> K;
  vector<vector<int>> sunuke(N, vector<int>(0));
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      sunuke.at(A).push_back(i);
    }
  }
  for (int i = 0; i < N; i++) {
    if (sunuke.at(i).size() == 0)
      x++;
  }
  cout << x << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  vector<int> a(100), d(100), e(101, 0);
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      scanf("%d", &a[j]);
      e[a[j]]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (e[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  vector<vector<int>> vec(n + 1, vector<int>(n + 1));
  vector<int> d(k), e(n + 1, 0);
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      scanf("%d", &vec[i][j]);
      e[vec[i][j]]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (e[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {

  int n, k;
  cin >> n >> k;
  vector<int> a(n);

  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    int tmp;
    rep(j, d) {
      cin >> tmp;
      tmp--;
      a.at(tmp)++;
    }
  }

  int ans = 0;
  rep(i, n) {
    if (a.at(i) == 0) {
      ans++;
    }
  }

  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {

  int n, k;
  cin >> n >> k;
  vector<int> a(n);

  rep(i, k) {

    int d;
    cin >> d;
    vector<int> ad(k);
    rep(j, d) {
      cin >> ad.at(j);
      ad.at(j)--;
      a.at(ad.at(j))++;
    }
  }

  int ans = 0;
  rep(i, n) {
    if (a.at(i) == 0) {
      ans++;
    }
  }

  cout << ans << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

// in the name of ALLAH
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n, k;
  cin >> n >> k;
  set<int> s;
  int d[k + 1];
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    int a[d[i] + 1];
    for (int j = 0; j < d[i]; j++) {
      cin >> a[j];
      s.insert(a[j]);
    }
  }
  cout << n - s.size() << endl;
}


Error: 0

Fixed submission:

// in the name of ALLAH
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n, k;
  cin >> n >> k;
  set<int> s;
  int d[n];
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    int a[d[i] + 1];
    for (int j = 0; j < d[i]; j++) {
      cin >> a[j];
      s.insert(a[j]);
    }
  }
  cout << n - s.size() << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<bool> have(N, false);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      have[A - 1] = true;
    }
  }

  int count = 0;
  for (int i = 0; i < N; i++) {
    if (!have[i]) {
      count++;
    }
  }
  cout << count << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void) {
  int N, K;
  vector<bool> have(N, false);
  cin >> N >> K;
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      have[A - 1] = true;
    }
  }

  int count = 0;
  for (int i = 0; i < N; i++) {
    if (!have[i]) {
      count++;
    }
  }
  cout << count << endl;

  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int n;
  int k;
  cin >> n >> k;
  bool flag[n + 1];
  for (int i = 0; i <= n; i++)
    flag[i] = false;
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int cur;
      cin >> cur;
      flag[cur] = true;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (flag[i] == false)
      ans += 1;
  }
  cout << ans << "\\n";
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n;
  int k;
  bool flag[n + 1];
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int cur;
      cin >> cur;
      flag[cur] = true;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (flag[i] == false)
      ans += 1;
  }
  cout << ans << "\\n";
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(a, b)                                                            \\
  if ((a) > (b))                                                               \\
    (a) = (b);
#define chmax(a, b)                                                            \\
  if ((a) < (b))                                                               \\
    (a) = (b);
#define vi vector<int>
#define pii pair<int, int>
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define pb push_back
#define pf push_front
int gcd(int a, int b) { /*a>=0,b>=0,￢(a=b=0)*/
  while (min(a, b) > 0) {
    if (a < b)
      swap(a, b);
    a %= b;
  }
  return max(a, b);
}
int dx[] = {0, 1, 0, -1, 1, -1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int MOD = 1e9 + 7;
const int INF = 1e18 + 10;

/*----------------------------------------------*/

signed main() {
  int n, k;
  cin >> n >> k;
  vi d(k);
  vector<vi> a(k, vi(n));
  rep(i, k) {
    cin >> d[i];
    rep(j, d[i]) cin >> a[i][j];
  }
  vi cnt(n + 1, 0);
  rep(i, k) rep(j, d[i]) { cnt[a[i][j]]++; }
  int ans = 0;
  FOR(i, 1, n) if (cnt[i] == 0) ans++;

  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(a, b)                                                            \\
  if ((a) > (b))                                                               \\
    (a) = (b);
#define chmax(a, b)                                                            \\
  if ((a) < (b))                                                               \\
    (a) = (b);
#define vi vector<int>
#define pii pair<int, int>
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define pb push_back
#define pf push_front
int gcd(int a, int b) { /*a>=0,b>=0,￢(a=b=0)*/
  while (min(a, b) > 0) {
    if (a < b)
      swap(a, b);
    a %= b;
  }
  return max(a, b);
}
int dx[] = {0, 1, 0, -1, 1, -1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int MOD = 1e9 + 7;
const int INF = 1e18 + 10;

/*----------------------------------------------*/

signed main() {
  int n, k;
  cin >> n >> k;
  vi d(k);
  vector<vi> a(k, vi(n));
  rep(i, k) {
    cin >> d[i];
    rep(j, d[i]) cin >> a[i][j];
  }
  vi cnt(n + 1, 0);
  rep(i, n) rep(j, d[i]) { cnt[a[i][j]]++; }
  int ans = 0;
  FOR(i, 1, n) if (cnt[i] == 0) ans++;

  cout << ans << endl;
  return 0;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  ll N, K;
  cin >> N >> K;
  set<ll> set;
  for (int i = 0; i < K; i++) {
    ll a;
    cin >> a;
    for (ll b = 0; b < a; b++) {
      ll c[b];
      cin >> c[b];
      set.insert(c[b]);
    }
  }
  cout << N - set.size() << endl;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int d[N];
  vector<vector<int>> A;
  int ans = 0;
  for (int i = 0; i < K; i++) {
    cin >> d[i];
    for (int a = 1; a < K; a++) {
      for (int b = 1; b <= N; b++) {
        if (b == A[a][d[i]]) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;

  vector<int> s(n);
  rep(i, k) {
    int m;
    cin >> m;

    rep(j, m) {
      int a;
      cin >> a;
      s[a - 1] = 1;
    }
  }

  int ans = 0;
  rep(i, n) if (s[i] == 0) ans++;

  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;

  vector<int> s(n);
  rep(i, k) {
    int m;
    cin >> m;

    rep(j, m) {
      int a;
      cin >> a;
      s[a] = 1;
    }
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 0)
      ans++;
  }

  cout << ans << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  int N, K, d, a;
  cin >> N >> K;
  vector<int> count(N);
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> a;
      count[a - 1] = 1;
    }
  }
  cout << N - accumulate(count.begin(), count.end(), 0) << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int N, K, d, a;
  cin >> N >> K;
  vector<int> count(N), A(d);
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> a;
      count[a - 1] = 1;
    }
  }

  cout << N - accumulate(count.begin(), count.end(), 0) << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> sunuke(N);

  for (int j = 0; j < K; j++) {

    int d;
    cin >> d;

    for (int i = 0; i < d; i++) {
      int A;
      cin >> A;
      sunuke.at(A - 1) = 1;
    }
  }

  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += sunuke.at(i);
  }

  cout << N - sum << endl;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> sunuke(N);

  for (int j = 0; j < K; j++) {

    int d;
    cin >> d;

    for (int i = 0; i < d; i++) {
      int A;
      cin >> A;
      sunuke.at(A) = 1;
    }
  }

  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += sunuke.at(i);
  }

  cout << N - sum << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  int N, K, count = 0; // N人とK種類,100以下
  cin >> N >> K;

  vector<int> d(K); // お菓子1を持ってるのはd人,1〜K＝100以下種類あるよ
  vector<int> A(N); // お菓子1を持ってるのはA人目、d人,必ずN＝100以下だよ
  vector<int> v(100); // お菓子を持ってる人の管理配列、N＝100以下人分

  for (int i = 0; i < K; i++) {
    cin >> d.at(i); // お菓子1は1人、お菓子2は1人、お菓子3は1人
    for (int j = 0; j < d.at(i); j++) {
      cin >> A.at(j); // お菓子1は3人目、お菓子2は3人目、お菓子3は3人目
      v.at(A.at(j) - 1) += A.at(j);
      // cout << v.at(A.at(j)-1) << " ";
      A.at(j) = 0;
    }
    // cout << endl;
  }

  for (int i = 0; i < 100; i++) {
    // cout << v.at(i) << " ";
    if (v.at(i) > 0)
      count++;
  }

  // cout << endl;
  // cout << count << endl;
  cout << (N - count) << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  int N, K, count = 0; // N人とK種類,100以下
  cin >> N >> K;

  vector<int> d(K); // お菓子1を持ってるのはd人,1〜K＝100以下種類あるよ
  vector<int> A(N); // お菓子1を持ってるのはA人目、d人,必ずN＝100以下だよ
  vector<int> v(10); // お菓子を持ってる人の管理配列、N＝100以下人分

  for (int i = 0; i < K; i++) {
    cin >> d.at(i); // お菓子1は1人、お菓子2は1人、お菓子3は1人
    for (int j = 0; j < d.at(i); j++) {
      cin >> A.at(j); // お菓子1は3人目、お菓子2は3人目、お菓子3は3人目
      v.at(A.at(j) - 1) += A.at(j);
      // cout << v.at(A.at(j)-1) << " ";
      A.at(j) = 0;
    }
    // cout << endl;
  }

  for (int i = 0; i < 10; i++) {
    // cout << v.at(i) << " ";
    if (v.at(i) > 0)
      count++;
  }

  // cout << endl;
  // cout << count << endl;
  cout << (N - count) << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, k, d, cnt;
  cin >> n >> k;
  vector<int> a(n, 0);

  int t = 0;
  for (int i = 0; i < k; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> t;
      a[t - 1] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    if (a[i] == 0)
      cnt++;
  }
  cout << cnt << endl;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n = 0;
  int k = 0;
  cin >> n;
  cin >> k;
  vector<vector<int>> a(k, vector<int>(n, 0));

  int d = 0;
  int tmp = 0;
  for (int i = 0; i < k; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> tmp;
      a[j][tmp - 1] = 1;
    }
  }

  int count = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      if (a[j][i] == 1) {
        count++;
        break;
      }
    }
  }
  cout << n - count << endl;
}
Problem p02688 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int d[K];
  int A[K][N];
  int have_bool[N];
  for (int i = 0; i < N; i++) {
    have_bool[i] = false;
  }

  for (int i = 0; i < K; ++i) {
    cin >> d[i];

    for (int j = 0; j < d[i]; ++j) {
      cin >> A[i][j];
      have_bool[A[i][j] - 1] = true;
    }
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (!have_bool[i])
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int d[K];
  int A[N][N];
  int have_bool[N];
  for (int i = 0; i < N; i++) {
    have_bool[i] = false;
  }

  for (int i = 0; i < K; ++i) {
    cin >> d[i];

    for (int j = 0; j < d[i]; ++j) {
      cin >> A[i][j];
      have_bool[A[i][j] - 1] = true;
    }
  }

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (!have_bool[i])
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}