Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repe(i, n) for (int i = 0; i <= n; ++i)
#define repr(i, n) for (int i = n - 1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using V = vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

double temp(int t, int h) {
  double s = t - h * 0.006;
  return s;
}

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> X(n);
  vector<int> Y(n);
  rep(i, n) { cin >> X[i]; }
  rep(i, m) { cin >> Y[i]; }
  for (int z = x + 1; z <= y; ++z) {
    bool bx = true, by = true;
    rep(i, n) {
      if (X[i] >= z) {
        bx = false;
      }
    }
    rep(i, m) {
      if (Y[i] < z) {
        by = false;
      }
    }
    if (bx == true && by == true) {
      cout << "No War"
           << "\n";
      return 0;
    }
  }

  cout << "War"
       << "\n";
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repe(i, n) for (int i = 0; i <= n; ++i)
#define repr(i, n) for (int i = n - 1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using V = vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

double temp(int t, int h) {
  double s = t - h * 0.006;
  return s;
}

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> X(n);
  vector<int> Y(m);
  rep(i, n) { cin >> X[i]; }
  rep(i, m) { cin >> Y[i]; }
  for (int z = x + 1; z <= y; ++z) {
    bool bx = true, by = true;
    rep(i, n) {
      if (X[i] >= z) {
        bx = false;
      }
    }
    rep(i, m) {
      if (Y[i] < z) {
        by = false;
      }
    }
    if (bx == true && by == true) {
      cout << "No War"
           << "\n";
      return 0;
    }
  }

  cout << "War"
       << "\n";
}