Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i, a, n) for (int i = a; i < (int)n; i++)
#define rf(i, n, a) for (int i = n; i >= a; i--)
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()
#define fill(a, v) memset(a, v, sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a, b) cout << a << " " << b << "\n"
#define d3(a, b, c) cout << a << " " << b << " " << c << "\n"
#define d4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios::sync_with_stdio(false), cin.tie(0);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;

const int MOD = inf + 7;

signed main() {
  fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  int a[3][3];
  f(i, 0, 3) f(j, 0, 3) cin >> a[i][j];

  map<int, int> m;
  int n;
  cin >> n;
  f(i, 0, n) {
    int x;
    cin >> x;
    m[x] = 1;
  }

  f(i, 0, 3) f(j, 0, 3) a[i][j] = m[a[i][j]];

  int ok = 0;
  if (a[0][0] && a[0][1] && a[0][2])
    ok = 1;
  if (a[1][0] && a[1][1] && a[1][2])
    ok = 1;
  if (a[2][0] && a[2][1] && a[2][2])
    ok = 1;

  if (a[0][0] && a[1][0] && a[2][0])
    ok = 1;
  if (a[0][1] && a[1][1] && a[2][1])
    ok = 1;
  if (a[0][2] && a[1][2] && a[2][2])
    ok = 1;

  if (a[0][0] && a[1][1] && a[2][2])
    ok = 1;
  if (a[2][0] && a[1][1] && a[0][2])
    ok = 1;

  cout << (ok ? "Yes" : "No");
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i, a, n) for (int i = a; i < (int)n; i++)
#define rf(i, n, a) for (int i = n; i >= a; i--)
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()
#define fill(a, v) memset(a, v, sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a, b) cout << a << " " << b << "\n"
#define d3(a, b, c) cout << a << " " << b << " " << c << "\n"
#define d4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios::sync_with_stdio(false), cin.tie(0);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;

const int MOD = inf + 7;

signed main() {
  fast;
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt" , "w" , stdout);
  // #endif

  int a[3][3];
  f(i, 0, 3) f(j, 0, 3) cin >> a[i][j];

  map<int, int> m;
  int n;
  cin >> n;
  f(i, 0, n) {
    int x;
    cin >> x;
    m[x] = 1;
  }

  f(i, 0, 3) f(j, 0, 3) a[i][j] = m[a[i][j]];

  int ok = 0;
  if (a[0][0] && a[0][1] && a[0][2])
    ok = 1;
  if (a[1][0] && a[1][1] && a[1][2])
    ok = 1;
  if (a[2][0] && a[2][1] && a[2][2])
    ok = 1;

  if (a[0][0] && a[1][0] && a[2][0])
    ok = 1;
  if (a[0][1] && a[1][1] && a[2][1])
    ok = 1;
  if (a[0][2] && a[1][2] && a[2][2])
    ok = 1;

  if (a[0][0] && a[1][1] && a[2][2])
    ok = 1;
  if (a[2][0] && a[1][1] && a[0][2])
    ok = 1;

  cout << (ok ? "Yes" : "No");
}