alexjercan/bugnet huggingface dataset:
Problem p00035 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  double xa, ya, xb, yb, xc, yc, xd, yd, s1, s2, s3, s4;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc,
               &xd, &yd) != EOF) {
    s1 = abs((xc - xa) * (yb - ya) - (xb - xa) * (yc - ya));
    s2 = abs((xc - xa) * (yd - ya) - (xd - xa) * (yc - ya));
    s3 = abs((xb - xa) * (yd - ya) - (xd - xa) * (yb - ya));
    s4 = abs((xb - xc) * (yd - yc) - (xd - xc) * (yb - yc));
    if (s1 + s2 == s3 + s4) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  double xa, ya, xb, yb, xc, yc, xd, yd, s1, s2, s3, s4;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc,
               &xd, &yd)) {
    s1 = abs((xc - xa) * (yb - ya) - (xb - xa) * (yc - ya));
    s2 = abs((xc - xa) * (yd - ya) - (xd - xa) * (yc - ya));
    s3 = abs((xb - xa) * (yd - ya) - (xd - xa) * (yb - ya));
    s4 = abs((xb - xc) * (yd - yc) - (xd - xc) * (yb - yc));
    if (s1 + s2 == s3 + s4) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
Problem p00035 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

using namespace std;

class Vector {
public:
  double x, y;

  Vector() {}
  Vector(double dx, double dy) {
    x = dx;
    y = dy;
  }
  Vector operator-(const Vector &hoge) {
    return Vector(x - hoge.x, y - hoge.y);
  }

  Vector operator-(const Vector &hoge) const {
    return Vector(x - hoge.x, y - hoge.y);
  }
};

double crossConduct(const Vector &lhs, const Vector &rhs) {
  return lhs.x * rhs.y - lhs.y * rhs.x;
}

double line(const Vector &a, const Vector &b, const Vector &p) {
  Vector hoge = b - a;
  Vector piyo = p - a;

  return crossConduct(hoge, piyo);
}

int main(int argc, char const *argv[]) {
  Vector A, B, C, D;
  char comma;

  while (cin >> A.x >> comma >> A.y >> comma >> B.x >> comma >> B.y >> comma >>
         C.x >> comma >> C.y >> comma >> D.x >> comma >> D.y) {
    double a, b, c, d;
    a = line(A, B, C);
    b = line(B, C, D);
    c = line(C, D, A);
    d = line(D, A, B);
    if ((a > 0 && b > 0 && c > 0 && d > 0) ||
        (a < 0 && b < 0 && c < 0 && d < 0))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

class Vector {
public:
  double x, y;

  Vector() {}
  Vector(double dx, double dy) {
    x = dx;
    y = dy;
  }
  Vector operator-(const Vector &hoge) {
    return Vector(x - hoge.x, y - hoge.y);
  }

  Vector operator-(const Vector &hoge) const {
    return Vector(x - hoge.x, y - hoge.y);
  }
};

double crossConduct(const Vector &lhs, const Vector &rhs) {
  return lhs.x * rhs.y - lhs.y * rhs.x;
}

double line(const Vector &a, const Vector &b, const Vector &p) {
  Vector hoge = b - a;
  Vector piyo = p - a;

  return crossConduct(hoge, piyo);
}

int main(int argc, char const *argv[]) {
  Vector A, B, C, D;

  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &A.x, &A.y, &B.x, &B.y, &C.x,
               &C.y, &D.x, &D.y)) {
    double a, b, c, d;
    a = line(A, B, C);
    b = line(B, C, D);
    c = line(C, D, A);
    d = line(D, A, B);
    if ((a > 0 && b > 0 && c > 0 && d > 0) ||
        (a < 0 && b < 0 && c < 0 && d < 0))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
Problem p00035 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

struct Vector {
  double x;
  double y;
};

bool is_c_inner(double xa, double ya, double xb, double yb, double xc,
                double yc, double xd, double yd) {
  Vector ab = Vector{xb - xa, yb - ya};
  Vector bc = Vector{xc - xb, yc - yb};

  Vector bd = Vector{xd - xb, yd - yb};
  Vector dc = Vector{xc - xd, yc - yd};

  Vector da = Vector{xa - xd, ya - yd};
  Vector ac = Vector{xc - xa, yc - ya};

  double cross_product_1 = ab.x * bc.y - ab.y * bc.x;
  double cross_product_2 = bd.x * dc.y - bd.y * dc.x;
  double cross_product_3 = da.x * ac.y - da.y * ac.x;

  return (cross_product_1 >= 0 && cross_product_2 >= 0 &&
          cross_product_3 >= 0) ||
         (cross_product_1 <= 0 && cross_product_2 <= 0 && cross_product_3 <= 0);
}

int main() {
  double xa, ya, xb, yb, xc, yc, xd, yd;
  string result;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc,
               &xd, &yd) == 8) {
    if (is_c_inner(xa, ya, xb, yb, xc, yc, xd, yd) ||
        is_c_inner(xb, yb, xc, yc, xd, yd, xa, ya) ||
        is_c_inner(xc, yc, xd, yd, xa, ya, xb, yb) ||
        is_c_inner(xd, yd, xa, ya, xb, yb, xc, yc)) {
      result = "NO"; // no convex
    } else {
      result = "YES"; // convex
    }
    cout << result << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

struct Vector {
  double x;
  double y;
};

bool is_c_inner(double xa, double ya, double xb, double yb, double xc,
                double yc, double xd, double yd) {
  Vector ab = Vector{xb - xa, yb - ya};
  Vector bc = Vector{xc - xb, yc - yb};

  Vector bd = Vector{xd - xb, yd - yb};
  Vector dc = Vector{xc - xd, yc - yd};

  Vector da = Vector{xa - xd, ya - yd};
  Vector ac = Vector{xc - xa, yc - ya};

  double cross_product_1 = ab.x * bc.y - ab.y * bc.x;
  double cross_product_2 = bd.x * dc.y - bd.y * dc.x;
  double cross_product_3 = da.x * ac.y - da.y * ac.x;

  return (cross_product_1 >= 0 && cross_product_2 >= 0 &&
          cross_product_3 >= 0) ||
         (cross_product_1 <= 0 || cross_product_2 <= 0 && cross_product_3 <= 0);
}

int main() {
  double xa, ya, xb, yb, xc, yc, xd, yd;
  string result;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc,
               &xd, &yd) != 0) {
    if (is_c_inner(xa, ya, xb, yb, xc, yc, xd, yd) ||
        is_c_inner(xb, yb, xc, yc, xd, yd, xa, ya) ||
        is_c_inner(xc, yc, xd, yd, xa, ya, xb, yb) ||
        is_c_inner(xd, yd, xa, ya, xb, yb, xc, yc)) {
      result = "NO"; // no convex
    } else {
      result = "YES"; // convex
    }
    cout << result << endl;
  }
  return 0;
}
Problem p00035 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
typedef pair<double, double> P;

double Helon(P pa, P pb, P pc) {
  double a, b, c;
  a = sqrt((pb.first - pa.first) * (pb.first - pa.first) +
           (pb.second - pa.second) * (pb.second - pa.second));
  b = sqrt((pc.first - pb.first) * (pc.first - pb.first) +
           (pc.second - pb.second) * (pc.second - pb.second));
  c = sqrt((pa.first - pc.first) * (pa.first - pc.first) +
           (pa.second - pc.second) * (pa.second - pc.second));
  double s = (a + b + c) / 2;
  return (sqrt(s * (s - a) * (s - b) * (s - c)));
}

void solve() {
  vector<P> p(4);
  while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &p[0].first, &p[0].second,
                &p[1].first, &p[1].second, &p[2].first, &p[2].second,
                &p[3].first, &p[3].second)) {
    double S1, S2;
    S1 = Helon(p[0], p[1], p[2]);
    S1 += Helon(p[0], p[2], p[3]);

    S2 = Helon(p[0], p[1], p[3]);
    S2 += Helon(p[1], p[2], p[3]);
    if (fabs(S1 - S2) < 1e-10) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

int main() {
  solve();
  return (0);
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
typedef pair<double, double> P;

double Helon(P pa, P pb, P pc) {
  double a, b, c;
  a = sqrt((pb.first - pa.first) * (pb.first - pa.first) +
           (pb.second - pa.second) * (pb.second - pa.second));
  b = sqrt((pc.first - pb.first) * (pc.first - pb.first) +
           (pc.second - pb.second) * (pc.second - pb.second));
  c = sqrt((pa.first - pc.first) * (pa.first - pc.first) +
           (pa.second - pc.second) * (pa.second - pc.second));
  double s = (a + b + c) / 2;
  return (sqrt(s * (s - a) * (s - b) * (s - c)));
}

void solve() {
  vector<P> p(4);
  while (scanf("%lf,%lf", &p[0].first, &p[0].second)) {
    for (int i = 1; i < 4; ++i) {
      scanf(",%lf,%lf", &p[i].first, &p[i].second);
    }
    double S1, S2;
    S1 = Helon(p[0], p[1], p[2]);
    S1 += Helon(p[0], p[2], p[3]);

    S2 = Helon(p[0], p[1], p[3]);
    S2 += Helon(p[1], p[2], p[3]);
    if (fabs(S1 - S2) < 1e-10) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

int main() {
  solve();
  return (0);
}
Problem p00035 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

#define rep(x, to) for (int x = 0; x < to; x++)
#define rep2(x, from, to) for (int x = from; x < to; x++)

using namespace std;

// 三角形面積（三点から）
double smen(double x1, double y1, double x2, double y2, double x3, double y3) {
  double wkk;

  wkk = ((x3 - x2) * (y1 - y2) - (x1 - x2) * (y3 - y2)) * 0.5;
  if (wkk < 0)
    wkk *= -1;
  return wkk;
}

int main(void) {

  double xa, xb, xc, xd, ya, yb, yc, yd;
  int cnt = 0;
  char k;
  while (!cin.eof() && cnt < 50) {
    cin >> xa >> k >> ya >> k >> xb >> k >> yb >> k >> xc >> k >> yc >> k >>
        xd >> k >> yd;
    if (cin.eof())
      break;

    double s1 = smen(xa, ya, xb, yb, xc, yc);
    double s1b = smen(xa, ya, xc, yc, xd, yd);
    double s2 = smen(xa, ya, xb, yb, xd, yd);
    double s2b = smen(xb, yb, xc, yc, xd, yd);
    if (s1 + s1b == s2 + s2b)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    //		cin.clear();
    cnt++;
  }
  return 0;
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

#define rep(x, to) for (int x = 0; x < to; x++)
#define rep2(x, from, to) for (int x = from; x < to; x++)

using namespace std;

// 三角形面積（三点から）
double smen(double x1, double y1, double x2, double y2, double x3, double y3) {
  return abs((x3 - x2) * (y1 - y2) - (x1 - x2) * (y3 - y2)) * 0.5;
}

int main(void) {

  int x[4], y[4];
  char c;

  while (scanf("%f,%f,%f,%f,%f,%f,%f,%f", &x[0], &y[0], &x[1], &y[1], &x[2],
               &y[2], &x[3], &y[3])) {
    // cin >>
    // x[0]>>c>>y[0]>>c>>x[1]>>c>>y[1]>>c>>x[2]>>c>>y[2]>>c>>x[3]>>c>>y[3];

    double s1 = smen(x[0], y[0], x[1], y[1], x[2], y[2]) +
                smen(x[2], y[2], x[3], y[3], x[0], y[0]);
    double s2 = smen(x[0], y[0], x[1], y[1], x[3], y[3]) +
                smen(x[2], y[2], x[1], y[1], x[3], y[3]);
    cout << ((s1 == s2) ? "YES" : "NO") << endl;
    //		cin.clear();
  }
  return 0;
}
Problem p00035 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

//??´???AB????§?????????´???BC????§??????????RotType????¨????(A???B???C????????§??????)
// RotType = ????????¢1, ????????¢-1, ??´???0
int getRotType(double angle_a, double angle_b) {
  const int eps = 1e-8;
  const double PAI = 3.14159265358979;

  if (fabs(angle_a - angle_b) <= eps)
    return 0;
  if (angle_a > angle_b + PAI)
    angle_b += 2 * PAI;
  else if (angle_b > angle_a + PAI)
    angle_a += 2 * PAI;

  if (angle_b > angle_a) //?§????????¢????????????????
    return 1;
  return -1; //?§???????????°?????????????
}

int main() {
  double x[4], y[4];
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &x[0], &y[0], &x[1], &y[1],
               &x[2], &y[2], &x[3], &y[3]) != -1) {
    // A???B???C, B???C???D,
    // C???D???A?????????????????¨???????????????????????????
    double ang[4];

    for (int i = 0; i < 4; i++)
      ang[i] = atan2(y[(i + 1) % 4] - y[i % 4], x[(i + 1) % 4] - x[i % 4]);

    double angType[4];
    for (int i = 0; i < 4; i++)
      angType[i] = getRotType(ang[i], ang[(i + 1) % 4]);

    int i;
    for (i = 0; i < 3; i++) {
      if (angType[i] != angType[i + 1])
        break;
    }
    if (i == 3)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

//??´???AB????§?????????´???BC????§??????????RotType????¨????(A???B???C????????§??????)
// RotType = ????????¢1, ????????¢-1, ??´???0
int getRotType(double angle_a, double angle_b) {
  const int eps = 1e-8;
  const double PAI = 3.14159265358979;

  if (fabs(angle_a - angle_b) <= eps)
    return 0;
  if (angle_a > angle_b + PAI)
    angle_b += 2 * PAI;
  else if (angle_b > angle_a + PAI)
    angle_a += 2 * PAI;

  if (angle_b > angle_a) //?§????????¢????????????????
    return 1;
  return -1; //?§???????????°?????????????
}

int main() {
  double x[4], y[4];
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &x[0], &y[0], &x[1], &y[1],
               &x[2], &y[2], &x[3], &y[3])) {
    // A???B???C, B???C???D,
    // C???D???A?????????????????¨???????????????????????????
    double ang[4];

    for (int i = 0; i < 4; i++)
      ang[i] = atan2(y[(i + 1) % 4] - y[i % 4], x[(i + 1) % 4] - x[i % 4]);

    double angType[4];
    for (int i = 0; i < 4; i++)
      angType[i] = getRotType(ang[i], ang[(i + 1) % 4]);

    int i;
    for (i = 0; i < 3; i++) {
      if (angType[i] != angType[i + 1])
        break;
    }
    if (i == 3)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
Problem p00035 (C++) — buggy submission, verdict: Runtime Error

#include <complex>
#include <cstdio>
#include <iostream>
using namespace std;

#define EPS 1e-7

typedef complex<double> P;
#define X real()
#define Y imag()

double cross(P a, P b) { return (a.X * b.Y) - (a.Y * b.X); }

int isIntersected(P a1, P a2, P b1, P b2) {
  return cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < EPS &&
         cross(b2 - b1, a1 - b1) * cross(b2 - b1, a2 - b1) < EPS;
}

int main() {
  double a, b, c, d, e, f, g, h;

  while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &a, &b, &c, &d, &e, &f, &g,
                &h)) {
    P aa(a, b), bb(c, d), cc(e, f), dd(g, h);
    cout << (isIntersected(aa, cc, bb, dd) > 0.0 ||
                     isIntersected(bb, dd, aa, cc) > 0.0
                 ? "YES"
                 : "NO")
         << endl;
  }

  return 0;
}

Error: -6
free(): invalid pointer


Fixed submission:

#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

float calc_crossProduct(float x1, float y1, float x2, float y2) {
  return (x1 * y2 - y1 * x2);
}

int main() {
  int cnt = 0;
  while (true) {
    string strall;
    cin >> strall;

    vector<float> x(4, 0.0);
    vector<float> y(4, 0.0);
    char c;
    for (int i = 0; i < 4; i++) {
      int pos = strall.find(",");
      //      cout << pos << endl;
      //      cout << strall.substr(0, pos) << endl;
      x[i] = std::stof(strall.substr(0, pos));

      strall.erase(strall.begin(), strall.begin() + pos + 1);
      //      cout << strall << endl;

      //      cout << strall.substr(0, pos) << endl;
      y[i] = std::stof(strall.substr(0, pos));
      strall.erase(strall.begin(), strall.begin() + pos + 1);
    }

    if (cnt < 2) {
      for (int i = 0; i < 4; i++) {
        //	cout << "(" << x[i] << ", " << y[i] << ")" << endl;
      }
      cnt++;
    }

    bool flag = true;
    vector<float> cp(4, 0.0);
    for (int i = 0; i < 4; i++) {

      float x1 = x[i];
      float y1 = y[i];
      float x2 = x[(i + 1) % 4];
      float y2 = y[(i + 1) % 4];
      float x3 = x[(i + 2) % 4];
      float y3 = y[(i + 2) % 4];

      float x2x1 = x2 - x1;
      float y2y1 = y2 - y1;
      float x3x1 = x3 - x1;
      float y3y1 = y3 - y1;

      cp[i] = calc_crossProduct(x2x1, y2y1, x3x1, y3y1);
      if (cp[i] < 0) {
        flag = false;
        break;
      }
    }

    if (flag != false) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
Problem p00035 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
using namespace std;
bool check(double x1, double y1, double x2, double y2, double x3, double y3,
           double x4, double y4) {
  if (x1 != x2) {
    double m = (y2 - y1) / (x2 - x1);
    if (y3 - y1 > m * (x3 - x1) && y4 - y1 < m * (x4 - x1))
      return true;
    else if (y3 - y1 < m * (x3 - x1) && y4 - y1 > m * (x4 - x1))
      return true;
    else
      return false;
  } else {
    if (x3 > x1 && x4 < x1)
      return true;
    else if (x3 < x1 && x4 > x1)
      return true;
    else
      return false;
  }
}
int main() {
  double xa, ya, xb, yb, xc, yc, xd, yd;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc,
               &xd, &yd) != EOF) {
    if (check(xa, ya, xc, yc, xb, yb, xd, yd) &&
        check(xb, yb, xd, yd, xa, ya, xc, yc))
      puts("YES");
    else
      puts("NO");
  }
}

Error: -11

Fixed submission:

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

using namespace std;

bool check(double x1, double y1, double x2, double y2, double x3, double y3,
           double x4, double y4) {
  double res1 = (y2 - y1) * (x3 - x1) / (x2 - x1) - (y3 - y1),
         res2 = (y2 - y1) * (x4 - x1) / (x2 - x1) - (y4 - y1);
  if (res1 > 0 && res2 > 0)
    return false;
  if (res1 < 0 && res2 < 0)
    return false;
  if (res1 == 0 || res2 == 0)
    return false;
  return true;
}
int main() {
  double a, b, c, d, e, f, g, h;
  while (scanf("%f,%f,%f,%f,%f,%f,%f,%f\\n", a, b, c, d, e, f, g, h) != EOF) {
    if (check(a, b, e, f, c, d, g, h) && check(c, d, g, h, a, b, e, f))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

struct pattern_t {
  int w;
  int h;
  char *pat;
  pattern_t(const int _w, const int _h, const char *_pat) {
    w = _w;
    h = _h;
    pat = new char[w * h];
    for (int i = 0; i < w * h; i++) {
      pat[i] = _pat[i];
    }
  }
  ~pattern_t() {
    if (pat) {
      delete[] pat;
      pat = 0;
    }
  }
};

int main() {
  pattern_t patA(2, 2, "1111"), patB(1, 4, "1111"), patC(4, 1, "1111"),
      patD(2, 3, "011110"), patE(3, 2, "110011"), patF(2, 3, "101101"),
      patG(3, 2, "011110");
  pattern_t *patterns[7] = {&patA, &patB, &patC, &patD, &patE, &patF, &patG};
  char field[8][8];
  while (1) {
    for (int i = 0; i < 8; i++) {
      string in;
      if (!(cin >> in))
        return 0;
      for (int j = 0; j < 8; j++) {
        field[i][j] = in[j];
      }
    }
    for (int sy = 0; sy < 8; sy++) {
      for (int sx = 0; sx < 8; sx++) {
        for (int p = 0; p < 7; p++) {
          pattern_t *pt = patterns[p];
          if (sy + pt->h > 8 || sx + pt->w > 8)
            continue;
          bool miss = false;
          for (int dy = 0; dy < pt->h; dy++) {
            for (int dx = 0; dx < pt->w; dx++) {
              if (pt->pat[dy * pt->w + dx] != field[sy + dy][sx + dx]) {
                miss = true;
                break;
              }
            }
            if (miss)
              break;
          }
          if (!miss) {
            cout << (char)('A' + p) << endl;
          }
        }
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;

string map[8];

void check(int x, int y) {
  int blocks[7][3][2] = {{{1, 0}, {0, 1}, {1, 1}}, {{0, 1}, {0, 2}, {0, 3}},
                         {{1, 0}, {2, 0}, {3, 0}}, {{0, 1}, {-1, 1}, {-1, 2}},
                         {{1, 0}, {1, 1}, {2, 1}}, {{0, 1}, {1, 1}, {1, 2}},
                         {{1, 0}, {0, 1}, {-1, 1}}};
  for (int i = 0; i < 7; i++) {
    bool match = true;
    for (int j = 0; j < 3; j++) {
      int xx = x + blocks[i][j][0];
      int yy = y + blocks[i][j][1];
      if (xx < 0 || xx >= 8 || yy < 0 || yy >= 8) {
        match = false;
        break;
      }
      if (map[yy][xx] == '0') {
        match = false;
      }
    }
    if (match) {
      cout << (char)('A' + i) << endl;
      break;
    }
  }
}

int main() {
  while (1) {
    int k = -1;
    for (int i = 0; i < 8; i++) {
      getline(cin, map[i]);
      if (map[i].length() != 8)
        return 0;
      if (k == -1 && map[i] != "00000000") {
        k = i;
      }
    }
    for (int i = 0; i < 8; i++) {
      if (map[k][i] == '1') {
        check(i, k);
        break;
      }
    }
    string br;
    getline(cin, br);
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
string s[8];
char f() {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (s[i][j] == '1') {
        if (i < 5)
          if (s[i + 3][j] == '1')
            return 'B';
        if (j < 5)
          if (s[i][j + 3] == '1')
            return 'C';
        if (i < 6 && j > 0)
          if (s[i + 2][j - 1] == '1')
            return 'D';
        if (i < 7 && j < 6)
          if (s[i + 1][j + 2] == '1')
            return 'E';
        if (i < 6 && j < 7)
          if (s[i + 2][j + 1] == '1')
            return 'F';
        if (i < 7 && j > 0)
          if (s[i + 1][j - 1] == '1' && s[i][j + 1])
            return 'G';
        return 'A';
      }
    }
  }
}

int main() {
  while (cin >> s[0]) {
    for (int i = 1; i < 8; i++)
      cin >> s[i];
    cout << f() << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
string s[8];
void f() {
  char b = 'A';
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (s[i][j] == '1') {
        if (i < 5)
          if (s[i + 3][j] == '1')
            b = 'B';
        if (j < 5)
          if (s[i][j + 3] == '1')
            b = 'C';
        if (i < 6 && j > 0)
          if (s[i + 2][j - 1] == '1')
            b = 'D';
        if (j < 6)
          if (s[i + 1][j + 2] == '1')
            b = 'E';
        if (i < 6)
          if (s[i + 2][j + 1] == '1')
            b = 'F';
        if (j > 0)
          if (s[i + 1][j - 1] == '1')
            b = 'G';
        cout << b << endl;
        return;
      }
    }
  }
}

int main() {
  while (cin >> s[0]) {
    for (int i = 1; i < 8; i++)
      cin >> s[i];
    f();
  }
  return 0;
}