Problem p00706 (C++) — buggy submission, verdict: Runtime Error

// include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \\
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

  int N;
  int d[210][210];
  int dp_x[210][210];
  int dp[210][210];
  while (cin >> N && N) {
    int W, H;
    fill((int *)d, (int *)d + 210 * 210, 0);
    cin >> W >> H;
    REP(i, N) {
      int x, y;
      cin >> x >> y;
      d[y][x] = 1;
    }
    int S, T;
    cin >> S >> T;

    fill((int *)dp_x, (int *)dp_x + 210 * 210, 0);
    REP(y, H + 1) {
      REP(i, S) dp_x[y][0] += d[y][i];
      for (int x = 1; x <= W; ++x) {
        dp_x[y][x] = dp_x[y][x - 1] - d[y][x - 1] + d[y][x + S - 1];
      }
    }

    // REP(y,H+1){REP(x,W+1)cout<< dp_x[y][x]<<" ";cout<<endl;}
    int ans = 0;
    fill((int *)dp, (int *)dp + 201 * 201, 0);
    REP(x, W + 1) {
      REP(i, T) dp[0][x] += dp_x[i][x];
      for (int y = 1; y <= H; ++y) {
        dp[y][x] = dp[y - 1][x] - dp_x[y - 1][x] + dp_x[y + T - 1][x];
        ans = max(ans, dp[y][x]);
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

// include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \\
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

  while (true) {
    int N;
    cin >> N;
    if (N == 0)
      break;
    int W, H;
    int d[210][210];
    fill((int *)d, (int *)d + 210 * 210, 0);
    cin >> W >> H;
    REP(i, N) {
      int x, y;
      cin >> x >> y;
      d[y][x] = 1;
    }
    int S, T;
    cin >> S >> T;

    int dp_x[210][210];
    fill((int *)dp_x, (int *)dp_x + 210 * 210, 0);
    REP(y, H + 1) {
      REP(i, S) dp_x[y][0] += d[y][i];
      for (int x = 1; x <= W; ++x) {
        dp_x[y][x] = dp_x[y][x - 1] - d[y][x - 1] + d[y][x + S - 1];
      }
    }

    // REP(y,H+1){REP(x,W+1)cout<< dp_x[y][x]<<" ";cout<<endl;}

    int dp[101][101], ans = 0;
    fill((int *)dp, (int *)dp + 201 * 201, 0);
    REP(x, W + 1) {
      REP(i, T) dp[0][x] += dp_x[i][x];
      for (int y = 1; y <= H; ++y) {
        dp[y][x] = dp[y - 1][x] - dp_x[y - 1][x] + dp_x[y + T - 1][x];
        ans = max(ans, dp[y][x]);
      }
    }
    cout << ans << endl;
  }

  return 0;
}