Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define PB push_back
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define PIE (3.14159265358979323846)
#define MOD 1000000007;
using namespace std;

void checkStream() {
#ifndef _DEBUG
  freopen("input.in", "r", stdin);
  freopen("output.out", "w", stdout);
#endif
}

void inMat(vector<vector<int>> &mat, const int &num) {
  bool found{false};
  for (auto &i : mat) {
    for (auto &j : i) {
      if (j == num) {
        found = true;
        j = 0;
        break;
      }
    }
    if (found)
      break;
  }
}

int main() {
  checkStream();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  // vector<vector<bool>> mat (3, vector<bool> (3, false));
  vector<vector<int>> mat(3, vector<int>(3));
  for (auto &i : mat) {
    for (auto &j : i)
      cin >> j;
  }

  int n{};
  cin >> n;
  while (n--) {
    int num{};
    cin >> num;

    inMat(mat, num);
  }

  bool found{true};
  for (int i{}; i < 3; ++i) {
    if (mat.at(i).at(i)) {
      found = false;
      break;
    }
  }

  if (found) {
    cout << "Yes" << endl;
    return 0;
  }
  found = true;
  for (int i{}, j{2}; i < 3; ++i, --j) {
    if (mat.at(i).at(j)) {
      found = false;
      break;
    }
  }
  if (found) {
    cout << "Yes" << endl;
    return 0;
  }

  for (int i{}; i < 3; ++i) {
    found = true;
    for (int j{}; j < 3; ++j) {
      if (mat.at(i).at(j)) {
        found = false;
        break;
      }
    }
    if (found) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  for (int i{}; i < 3; ++i) {
    found = true;
    for (int j{}; j < 3; ++j) {
      if (mat.at(j).at(i)) {
        found = false;
        break;
      }
    }
    if (found) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define PB push_back
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define PIE (3.14159265358979323846)
#define MOD 1000000007;
using namespace std;

void checkStream() {
#ifndef _DEBUG
  freopen("input.in", "r", stdin);
  freopen("output.out", "w", stdout);
#endif
}

void inMat(vector<vector<int>> &mat, const int &num) {
  bool found{false};
  for (auto &i : mat) {
    for (auto &j : i) {
      if (j == num) {
        found = true;
        j = 0;
        break;
      }
    }
    if (found)
      break;
  }
}

int main() {
  // checkStream();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  // vector<vector<bool>> mat (3, vector<bool> (3, false));
  vector<vector<int>> mat(3, vector<int>(3));
  for (auto &i : mat) {
    for (auto &j : i)
      cin >> j;
  }

  int n{};
  cin >> n;
  while (n--) {
    int num{};
    cin >> num;

    inMat(mat, num);
  }

  bool found{true};
  for (int i{}; i < 3; ++i) {
    if (mat.at(i).at(i)) {
      found = false;
      break;
    }
  }

  if (found) {
    cout << "Yes" << endl;
    return 0;
  }
  found = true;
  for (int i{}, j{2}; i < 3; ++i, --j) {
    if (mat.at(i).at(j)) {
      found = false;
      break;
    }
  }
  if (found) {
    cout << "Yes" << endl;
    return 0;
  }

  for (int i{}; i < 3; ++i) {
    found = true;
    for (int j{}; j < 3; ++j) {
      if (mat.at(i).at(j)) {
        found = false;
        break;
      }
    }
    if (found) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  for (int i{}; i < 3; ++i) {
    found = true;
    for (int j{}; j < 3; ++j) {
      if (mat.at(j).at(i)) {
        found = false;
        break;
      }
    }
    if (found) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}