Problem p03404 (C++)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for (auto i = (m).begin(); i != (m).end(); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template <typename T> void printv(vector<T> const &s) {
  REP(i, SZ(s)) { cout << s[i] << " "; }
  cout << endl;
}

int main() {
  cin.tie(0);
  cout << setprecision(10);

  int a, b;
  cin >> a >> b;
  a--;
  b--;
  cout << 100 << " " << 100 << endl;
  vector<string> v(100);
  REP(i, 100) {
    REP(j, 100) {
      if (j < 50)
        v[i].pb('#');
      else
        v[i].pb('.');
    }
  }

  int cnta = 0;
  P posa = make_pair(0, 0);
  while (cnta < a) {
    v[posa.fi][posa.se] = '.';
    if (posa.se != 48)
      posa.se += 2;
    else {
      posa.fi += 2;
      posa.se = 0;
    }
    cnta++;
  }

  int cntb = 0;
  P posb = make_pair(0, 51);
  while (cntb < b) {
    v[posb.fi][posb.se] = '#';
    if (posb.se != 99)
      posb.se += 2;
    else {
      posb.fi += 2;
      posb.se = 0;
    }
    cntb++;
  }

  REP(i, 100) {
    REP(j, 100) { cout << v[i][j]; }
    cout << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for (auto i = (m).begin(); i != (m).end(); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template <typename T> void printv(vector<T> const &s) {
  REP(i, SZ(s)) { cout << s[i] << " "; }
  cout << endl;
}

int main() {
  cin.tie(0);
  cout << setprecision(10);

  int a, b;
  cin >> a >> b;
  a--;
  b--;
  cout << 100 << " " << 100 << endl;
  vector<string> v(100);
  REP(i, 100) {
    REP(j, 100) {
      if (j < 50)
        v[i].pb('#');
      else
        v[i].pb('.');
    }
  }

  int cnta = 0;
  P posa = make_pair(0, 0);
  while (cnta < a) {
    v[posa.fi][posa.se] = '.';
    if (posa.se != 48)
      posa.se += 2;
    else {
      posa.fi += 2;
      posa.se = 0;
    }
    cnta++;
  }

  int cntb = 0;
  P posb = make_pair(0, 51);
  while (cntb < b) {
    v[posb.fi][posb.se] = '#';
    if (posb.se != 99)
      posb.se += 2;
    else {
      posb.fi += 2;
      posb.se = 51;
    }
    cntb++;
  }

  REP(i, 100) {
    REP(j, 100) { cout << v[i][j]; }
    cout << endl;
  }
}