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

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

// #define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(a) (a).begin(), (a).end()
#define dump(o)                                                                \\
  { cerr << #o << " " << o << endl; }
#define dumpc(o)                                                               \\
  {                                                                            \\
    cerr << #o;                                                                \\
    for (auto &e : (o))                                                        \\
      cerr << " " << e;                                                        \\
    cerr << endl;                                                              \\
  }
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
  char c[110][110] = {};
  int cnt[110][110] = {};
  for (int H, W; cin >> H >> W && H;) {
    memset(cnt, 0, sizeof(cnt));
    rep(i, 0, H) rep(j, 0, W) cin >> c[i][j];
    int i = 0, j = 0;
    while (true) {
      cnt[i][j]++;
      if (cnt[i][j] > 10) {
        cout << "LOOP" << endl;
        break;
      } else {
        bool flag = false;
        switch (c[i][j]) {
        case '.':
          cout << j << " " << i << endl;
          flag = true;
          break;
        case '>':
          j++;
          break;
        case '<':
          j--;
          break;
        case '^':
          i--;
          break;
        case 'v':
          i++;
          break;
        default:
          break;
        }
        if (flag)
          break;
      }
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

// #define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(a) (a).begin(), (a).end()
#define dump(o)                                                                \\
  { cerr << #o << " " << o << endl; }
#define dumpc(o)                                                               \\
  {                                                                            \\
    cerr << #o;                                                                \\
    for (auto &e : (o))                                                        \\
      cerr << " " << e;                                                        \\
    cerr << endl;                                                              \\
  }
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
  for (int H, W; cin >> H >> W && H;) {
    char c[12][12] = {};
    rep(i, 0, H) rep(j, 0, W) cin >> c[i][j];
    int cnt[12][12] = {};
    int i = 0, j = 0;
    while (true) {
      cnt[i][j]++;
      if (cnt[i][j] > 10) {
        cout << "LOOP" << endl;
        break;
      } else {
        bool flag = false;
        switch (c[i][j]) {
        case '.':
          cout << j << " " << i << endl;
          flag = true;
          break;
        case '>':
          j++;
          break;
        case '<':
          j--;
          break;
        case '^':
          i--;
          break;
        case 'v':
          i++;
          break;
        default:
          break;
        }
        if (flag)
          break;
      }
    }
  }
  return 0;
}