Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define MAXN 100005
#define mod 1000000007
#define inf LLONG_MAX / 3
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

ll power(ll x, ll y, ll m = mod) {
  ll ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans = (ans * x) % m;
    }
    x = (x * x) % m;
    y /= 2;
  }
  return ans % m;
}

ll modInverse(ll a, ll m = mod) {
  ll m0 = m;
  ll y = 0, x = 1;

  if (m == 1)
    return 0;

  while (a > 1) {
    // q is quotient
    ll q = a / m;
    ll t = m;

    // m is remainder now, process same as
    // Euclid's algo
    m = a % m, a = t;
    t = y;

    // Update y and x
    y = x - q * y;
    x = t;
  }

  // Make x positive
  if (x < 0)
    x += m0;

  return x;
}

ll get(string s) {
  ll res = 0;
  for (int i = 0; i < s.length(); i++) {
    res += s[i] - '0';
    res *= 10;
  }
  return res / 10;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll t = 1;
  // cin>>t;
  while (t--) {
    ll n, m, i, j, ans = 0;
    ll a[3][3], mark[3][3];
    map<ll, pll> mp;
    for (i = 0; i < 3; i++) {
      for (j = 0; j < 3; j++) {
        cin >> a[i][j];
        mark[i][j] = 0;
        mp[a[i][j]] = {i, j};
      }
    }
    cin >> n;
    while (n--) {
      cin >> m;
      if (mp.find(m) != mp.end()) {
        auto it = mp.find(m);
        mark[it->second.first][it->second.second] = 1;
      }
    }
    for (i = 0; i < 3; i++) {
      for (j = 0; j < 3; j++) {
        a[i][j] = mark[i][j];
        // cout<<mark[i][j]<<" ";
      }
      // cout<<"\n";
    }
    if (a[0][0] + a[0][1] + a[0][2] == 3 || a[1][0] + a[1][1] + a[1][2] == 3 ||
        a[2][0] + a[2][1] + a[2][2] == 3 || a[0][0] + a[1][0] + a[2][0] == 3 ||
        a[0][1] + a[1][1] + a[2][1] == 3 || a[0][2] + a[1][2] + a[2][2] == 3 ||
        a[0][0] + a[1][1] + a[2][2] == 3 || a[0][2] + a[1][1] + a[2][0] == 3) {
      cout << "Yes";
    } else {
      cout << "No\n";
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define MAXN 100005
#define mod 1000000007
#define inf LLONG_MAX / 3
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

ll power(ll x, ll y, ll m = mod) {
  ll ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans = (ans * x) % m;
    }
    x = (x * x) % m;
    y /= 2;
  }
  return ans % m;
}

ll modInverse(ll a, ll m = mod) {
  ll m0 = m;
  ll y = 0, x = 1;

  if (m == 1)
    return 0;

  while (a > 1) {
    // q is quotient
    ll q = a / m;
    ll t = m;

    // m is remainder now, process same as
    // Euclid's algo
    m = a % m, a = t;
    t = y;

    // Update y and x
    y = x - q * y;
    x = t;
  }

  // Make x positive
  if (x < 0)
    x += m0;

  return x;
}

ll get(string s) {
  ll res = 0;
  for (int i = 0; i < s.length(); i++) {
    res += s[i] - '0';
    res *= 10;
  }
  return res / 10;
}

int main() {
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll t = 1;
  // cin>>t;
  while (t--) {
    ll n, m, i, j, ans = 0;
    ll a[3][3], mark[3][3];
    map<ll, pll> mp;
    for (i = 0; i < 3; i++) {
      for (j = 0; j < 3; j++) {
        cin >> a[i][j];
        mark[i][j] = 0;
        mp[a[i][j]] = {i, j};
      }
    }
    cin >> n;
    while (n--) {
      cin >> m;
      if (mp.find(m) != mp.end()) {
        auto it = mp.find(m);
        mark[it->second.first][it->second.second] = 1;
      }
    }
    for (i = 0; i < 3; i++) {
      for (j = 0; j < 3; j++) {
        a[i][j] = mark[i][j];
        // cout<<mark[i][j]<<" ";
      }
      // cout<<"\n";
    }
    if (a[0][0] + a[0][1] + a[0][2] == 3 || a[1][0] + a[1][1] + a[1][2] == 3 ||
        a[2][0] + a[2][1] + a[2][2] == 3 || a[0][0] + a[1][0] + a[2][0] == 3 ||
        a[0][1] + a[1][1] + a[2][1] == 3 || a[0][2] + a[1][2] + a[2][2] == 3 ||
        a[0][0] + a[1][1] + a[2][2] == 3 || a[0][2] + a[1][1] + a[2][0] == 3) {
      cout << "Yes";
    } else {
      cout << "No\n";
    }
  }
  return 0;
}