Problem p01552 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, a) repi(i, 0, a)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define repit(i, a)                                                            \
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)

#define all(u) (u).begin(), (u).end()
#define rall(u) (u).rbegin(), (u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)), (u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

string prop[32];

int main() {
  rep(i, 32) prop[i] = "";
  string in;
  cin >> in;
  int sz = 0;
  rep(i, in.size()) {
    if (in[i] == '.')
      sz++;
    else
      prop[sz - 1] += in[i];
  }
  int pos = 0;
  int depth = 0;
  int prev = 0;
  bool flag = false;
  int indents[32];
  cin.ignore();
  while (getline(cin, in)) {
    if (in.size() == 0)
      break;
    int cur = 0;
    while (in[cur] == ' ')
      cur++;

    string tag = "", str = "";
    int t = cur;
    while (in[t] != ':')
      tag += in[t++];
    t += 2;
    while (t < in.size())
      str += in[t++];

    if (cur > prev) {
      depth++;
      indents[depth] = cur;
    }
    if (cur < prev) {
      while (indents[depth] > cur)
        depth--;
    }
    if (depth < pos) {
      pos = depth;
    }

    if (depth == pos && prop[pos] == tag) {
      pos++;
      if (pos == sz) {
        if (str.size() == 0)
          cout << "object\n";
        else
          cout << "string \"" << str << "\"\n";
        return 0;
      }
    }
    prev = cur;
  }
  cout << "no such property\n";
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, a) repi(i, 0, a)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define repit(i, a)                                                            \
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)

#define all(u) (u).begin(), (u).end()
#define rall(u) (u).rbegin(), (u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)), (u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

string prop[32];

int main() {
  rep(i, 32) prop[i] = "";
  string in;
  cin >> in;
  int sz = 0;
  rep(i, in.size()) {
    if (in[i] == '.')
      sz++;
    else
      prop[sz - 1] += in[i];
  }
  int pos = 0;
  int depth = 0;
  int prev = 0;
  bool flag = false;
  int indents[50000] = {0};
  cin.ignore();
  while (getline(cin, in)) {
    if (in.size() == 0)
      break;
    int cur = 0;
    while (in[cur] == ' ')
      cur++;

    string tag = "", str = "";
    int t = cur;
    while (in[t] != ':')
      tag += in[t++];
    t += 2;
    while (t < in.size())
      str += in[t++];

    if (cur > prev) {
      depth++;
      indents[depth] = cur;
    }
    if (cur < prev) {
      while (indents[depth] > cur)
        depth--;
    }
    if (depth < pos) {
      pos = depth;
    }

    if (depth == pos && prop[pos] == tag) {
      pos++;
      if (pos == sz) {
        if (str.size() == 0)
          cout << "object\n";
        else
          cout << "string \"" << str << "\"\n";
        return 0;
      }
    }
    prev = cur;
  }
  cout << "no such property\n";
  return 0;
}