Problem p00036 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
char s[8][8];
int main() {

  while (cin >> s[0][0]) {
    for (int j = 1; j < 8; j++) {
      cin >> s[0][j];
    }
    for (int i = 1; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        cin >> s[i][j];
      }
    }
    for (int y = 0; y < 8; y++) {
      for (int x = 0; x < 8; x++) {
        if (s[y][x] == '1' && s[y + 1][x] == '1' && s[y][x + 1] == '1' &&
            s[y + 1][x + 1] == '1')
          cout << "A" << endl;
        else if (s[y][x] == '1' && s[y + 1][x] == '1' && s[y + 2][x] == '1' &&
                 s[y + 3][x] == '1')
          cout << "B" << endl;
        else if (s[y][x] == '1' && s[y][x + 1] == '1' && s[y][x + 2] == '1' &&
                 s[y][x + 3] == '1')
          cout << "C" << endl;
        else if (s[y][x] == '1' && s[y + 1][x] == '1' &&
                 s[y + 1][x - 1] == '1' && s[y + 2][x - 1] == '1')
          cout << "D" << endl;
        else if (s[y][x] == '1' && s[y][x + 1] == '1' &&
                 s[y + 1][x + 1] == '1' && s[y + 1][x + 2] == '1')
          cout << "E" << endl;
        else if (s[y][x] == '1' && s[y + 1][x] == '1' &&
                 s[y + 1][x + 1] == '1' && s[y + 2][x + 1] == '1')
          cout << "F" << endl;
        else if (s[y][x] == '1' && s[y][x + 1] == '1' && s[y + 1][x] == '1' &&
                 s[y + 1][x - 1] == '1')
          cout << "G" << endl;
      }
    }
  }
}

Error: TLE

Fixed submission:

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
char s[100][100];
int main() {

  while (1) {
    int x, y;
    bool f = false;
    for (int i = 1; i <= 8; i++) {
      for (int j = 1; j <= 8; j++) {
        cin >> s[i][j];
        if (s[i][j] == '1' && !f) {
          y = i;
          x = j;
          f = true;
        }
      }
    }

    if (s[y][x] == '1' && s[y + 1][x] == '1' && s[y][x + 1] == '1' &&
        s[y + 1][x + 1] == '1')
      cout << "A" << endl;
    else if (s[y][x] == '1' && s[y + 1][x] == '1' && s[y + 2][x] == '1' &&
             s[y + 3][x] == '1')
      cout << "B" << endl;
    else if (s[y][x] == '1' && s[y][x + 1] == '1' && s[y][x + 2] == '1' &&
             s[y][x + 3] == '1')
      cout << "C" << endl;
    else if (s[y][x] == '1' && s[y + 1][x] == '1' && s[y + 1][x - 1] == '1' &&
             s[y + 2][x - 1] == '1')
      cout << "D" << endl;
    else if (s[y][x] == '1' && s[y][x + 1] == '1' && s[y + 1][x + 1] == '1' &&
             s[y + 1][x + 2] == '1')
      cout << "E" << endl;
    else if (s[y][x] == '1' && s[y + 1][x] == '1' && s[y + 1][x + 1] == '1' &&
             s[y + 2][x + 1] == '1')
      cout << "F" << endl;
    else if (s[y][x] == '1' && s[y][x + 1] == '1' && s[y + 1][x] == '1' &&
             s[y + 1][x - 1] == '1')
      cout << "E" << endl;
  }
}