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

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < (int)(n); i++)

const int INF = 10000000;
using namespace std;
typedef long long ll;

/** Problem0092 : Square Searching
 !! TLE !! **/
int d[1010][1010];
char c[1010][1010];
int n;

bool check(int i) {
  REP(y, 1, n + 1) {
    REP(x, 1, n + 1) {
      if (x - i >= 0 && y - i >= 0 &&
          i * i == d[x][y] - d[x - i][y] - d[x][y - i] + d[x - i][y - i])
        return true;
    }
  }
  return false;
}

int main() {
  while (cin >> n, n) {
    rep(i, n) {
      rep(j, n) {
        char cc;
        cin >> cc;
        c[j][i] = cc;
      }
    }

    rep(i, 1010) {
      d[i][0] = 0;
      d[0][i] = 0;
    }

    REP(i, 1, n + 1) {
      REP(j, 1, n + 1) {
        if (c[j - 1][i - 1] == '.') {
          d[j][i] = 1 + d[j - 1][i] + d[j][i - 1] - d[j - 1][i - 1];
        } else {
          d[j][i] = d[j - 1][i] + d[j][i - 1] - d[j - 1][i - 1];
        }
      }
    }
    int lb = 0, ub = INF;

    rep(i, 100) {
      int mid = (lb + ub) / 2;
      if (!check(mid)) {
        ub = mid;
      } else {
        lb = mid;
      }
    }
    cout << lb << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include "math.h"
#include "stdio.h"

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < (int)(n); i++)

const int INF = 10000000;
using namespace std;
typedef long long ll;

/** Problem0092 : Square Searching **/
int main() {
  int d[1010][1010];
  char c[1000][1000];
  int n;

  while (cin >> n, n) {
    rep(i, n) {
      rep(j, n) {
        char cc;
        cin >> cc;
        c[j][i] = cc;
      }
    }

    rep(i, 1010) {
      d[i][0] = 0;
      d[0][i] = 0;
    }

    REP(i, 1, n + 1) {
      REP(j, 1, n + 1) {
        if (c[j - 1][i - 1] == '.') {
          d[j][i] = 1 + d[j - 1][i] + d[j][i - 1] - d[j - 1][i - 1];
        } else {
          d[j][i] = d[j - 1][i] + d[j][i - 1] - d[j - 1][i - 1];
        }
      }
    }
    int max = 0;
    REP(i, 1, n + 1) {
      REP(y, 1, n + 1) {
        REP(x, 1, n + 1) {
          if (i * i == d[x][y] - d[x - i][y] - d[x][y - i] + d[x - i][y - i])
            goto find;
        }
      }
      break;
    find:
      if (max < i)
        max = i;
    }
    cout << max << endl;
  }
  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;
int main() {
  int n;
  for (; cin >> n, n;) {
    string map[n];
    int sum[n][n];
    for (int i = 0; i < n; i++) {
      cin >> map[i];
      for (int j = 0; j < n; j++) {
        int tmp = 0;
        if (j > 0)
          tmp += sum[i][j - 1];
        if (i > 0)
          tmp += sum[i - 1][j];
        if (j > 0 && i > 0)
          tmp -= sum[i - 1][j - 1];
        if (map[i][j] == '.')
          tmp++;
        sum[i][j] = tmp;
      }
    }
    /*      cout<<endl;
    for(int i=0;i<n;i++,cout<<endl)
      for(int j=0;j<n;j++)
      printf("%3d ",sum[i][j]);*/
    int ans = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        for (int x = min(i, j); x >= ans; x--) {
          int tmp = sum[i][j];
          if (i - x > 0)
            tmp -= sum[i - x - 1][j];
          if (j - x > 0)
            tmp -= sum[i][j - x - 1];
          if (i - x > 0 && j - x > 0)
            tmp += sum[i - x - 1][j - x - 1];
          if ((x + 1) * (x + 1) == tmp)
            ans = max(x + 1, ans);
        }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;
int main() {
  int n;
  for (; cin >> n, n;) {
    string map[n];
    int sum[n][n];
    for (int i = 0; i < n; i++) {
      cin >> map[i];
      for (int j = 0; j < n; j++) {
        int tmp = 0;
        if (j > 0)
          tmp += sum[i][j - 1];
        if (i > 0)
          tmp += sum[i - 1][j];
        if (j > 0 && i > 0)
          tmp -= sum[i - 1][j - 1];
        if (map[i][j] == '.')
          tmp++;
        sum[i][j] = tmp;
      }
    }
    /*      cout<<endl;
    for(int i=0;i<n;i++,cout<<endl)
      for(int j=0;j<n;j++)
      printf("%3d ",sum[i][j]);*/
    int ans = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        for (int x = min(i, j); x >= 0; x--) {
          int tmp = sum[i][j];
          if (i - x > 0)
            tmp -= sum[i - x - 1][j];
          if (j - x > 0)
            tmp -= sum[i][j - x - 1];
          if (i - x > 0 && j - x > 0)
            tmp += sum[i - x - 1][j - x - 1];
          if ((x + 1) * (x + 1) == tmp)
            ans = max(x + 1, ans);
        }
    cout << ans << endl;
  }
}
Problem p00092 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
char ma[1001][1001];
int main() {
  int n;
  while (cin >> n, n) {

    int d[1001][1001] = {{0}};

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> ma[j][i];
      }
    }

    for (int i = 0; i < n; i++) {
      if (ma[i][0] != '*')
        d[i][0] = 1;
      else
        d[i][0] = 0;
      if (ma[0][i] != '*')
        d[0][i] = 1;
      else
        d[0][i] = 0;
    }
    int MSquare = 0;
    for (int i = 1; i < n; i++) {
      for (int j = 1; j < n; j++) {
        if (ma[i][j] == '*') {
          d[i][j] = 0;
        } else {
          d[i][j] = min(d[i - 1][j - 1], min(d[i - 1][j], d[i][j - 1])) + 1;
          MSquare = max(MSquare, d[i][j]);
        }
      }
    }

    cout << MSquare << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  char ma[100][100];
  int n;
  while (cin >> n, n) {

    int d[100][100] = {{0}};

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> ma[j][i];
      }
    }
    for (int i = 0; i < n; i++) {
      if (ma[i][0] != '*')
        d[i][0] = 1;
      else
        d[i][0] = 0;
      if (ma[0][i] != '*')
        d[0][i] = 1;
      else
        d[0][i] = 0;
    }
    int MSquare = 0;
    for (int i = 1; i < n; i++) {
      for (int j = 1; j < n; j++) {
        if (ma[i][j] == '*') {
          d[i][j] = 0;
        } else {
          d[i][j] = min(d[i - 1][j - 1], min(d[i - 1][j], d[i][j - 1])) + 1;
          MSquare = max(MSquare, d[i][j]);
        }
      }
    }

    cout << MSquare << endl;
  }
  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>

using namespace std;

int n;

void solve() {
  vector<string> map(n);
  vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
  int ans = 0;

  for (int i = 0; i < n; i++)
    cin >> map[i];

  for (int i = 0; i < n; i++)
    if (map[i][0] == '.')
      dp[i][0] = 1;
  for (int i = 0; i < n; i++)
    if (map[0][i] == '.')
      dp[0][i] = 1;

  for (int i = 1; i < n; i++)
    for (int j = 1; j < n; j++) {
      if (map[i][j] == '*')
        dp[i][j] = 0;
      else {
        dp[i][j] = min(min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1;
        ans = max(ans, dp[i][j]);
      }
    }
  cout << ans << endl;
}

int main() {
  while (cin >> n, n) {
    solve();
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int n;

void solve() {
  vector<string> map(n);
  vector<vector<int>> sum(n, vector<int>(n + 1, 0));
  int ans = 0;

  for (int i = 0; i < n; i++)
    cin >> map[i];
  for (int i = 0; i < n; i++)
    for (int j = n - 1; j >= 0; j--)
      if (map[i][j] == '.')
        sum[i][j] = sum[i][j + 1] + 1;
  // for (int i = 0; i < n; i++) {
  //     for (int j = 0; j < n; j++)
  //         cout << sum[i][j] << " ";
  //     cout << endl;
  // }
  // cout << endl;

  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (map[i][j] == '.') {
        int h = 1, w = sum[i][j];
        int tmp = min(h, w);

        while (i + h < n) {
          w = min(w, sum[i + h][j]);
          h++;

          if (w < h)
            break;
          if (min(h, w) < tmp)
            break;
          if (h > ans)
            ans = h;
          tmp = min(h, w);
        }
      }
  cout << ans << endl;
}

int main() {
  while (cin >> n, n) {
    solve();
  }

  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <cstring>
// #include <cstdlib>
// #include <cmath>
// #include <string>
#include <algorithm>
// #include <vector>
#define INF (2000000000)
using namespace std;

// typedef vector<int> VI;
// typedef vector<int>::iterator VII;
// typedef vector<double> VD;
// typedef vector<double>::iterator VDI;

char map[2048][2048];
int dp[2048][2048];

int main() {
  int n;
  while (scanf("%d", &n), n) {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < 1024; i++) {
      for (int j = 0; j < 1024; j++) {
        map[i][j] = '\\0';
      }
    }

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        scanf(" %c", &map[i][j]);
      }
    }

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (map[i][j] == '.') {
          dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
        }
        //			printf("%d", dp[i][j]);
      }
      //		printf("\\n");
    }

    int maxi = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        maxi = max(maxi, dp[i][j]);
      }
    }

    printf("%d\\n", maxi);
  }

  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <cstring>
// #include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#define INF (2000000000)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;

char map[1024][1024];
int dp[1024][1024];

int main() {
  int n;
  while (scanf("%d", &n), n) {
    memset(dp, 0, sizeof(dp));
    memset(map, 0, sizeof(dp));

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        scanf(" %c", &map[i][j]);
      }
    }

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (map[i][j] == '.') {
          dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
        }
        //			printf("%d", dp[i][j]);
      }
      //		printf("\\n");
    }

    int maxi = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        maxi = max(maxi, dp[i][j]);
      }
    }

    printf("%d\\n", maxi);
  }

  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  while (cin >> n, n) {
    vector<string> V;
    while (n--) {
      string tmp;
      cin >> tmp;
      V.push_back(tmp);
    }
    n = V.size();
    vector<vector<int>> N(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n - 1; j++) {
        if (V[i][j] == '.')
          N[i][j]++;
        if (V[i][j] == V[i][j + 1] && V[i][j] == '.') {
          N[i][j + 1] += N[i][j];
        }
      }
      if (V[i][n - 1] == '*')
        N[i][n - 1] = 0;
      else
        N[i][n - 1]++;
    }
    int res = 0;
    for (int i = 0; i < N.size(); i++) {
      for (int j = 0; j < N[i].size(); j++) {
        if (N[i][j] > res) {
          int t = N[i][j];
          bool flag = true;
          for (int k = 0; k < t; k++) {
            if (i + k >= n) {
              flag = false;
              break;
            }
            if (N[i + k][j] < t) {
              t = N[i + k][j];
            }
          }
          if (flag && res < t) {
            res = t;
          }
        }
      }
    }
    cout << res << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int n;
  while (cin >> n, n) {
    vector<string> V;
    while (n--) {
      string tmp;
      cin >> tmp;
      V.push_back(tmp);
    }
    n = V.size();
    vector<vector<int>> N(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n - 1; j++) {
        if (V[i][j] == V[i][j + 1] && V[i][j] == '.') {
          N[i][j + 1] += ++N[i][j];
        }
      }
      if (V[i][n - 1] == '*')
        N[i][n - 1] = 0;
    }
    int res = 0;
    for (int i = 0; i < N.size(); i++) {
      for (int j = 0; j < N[i].size(); j++) {
        if (N[i][j] > res) {
          int t = N[i][j];
          bool flag = true;
          for (int k = 0; k < t; k++) {
            if (N[i + k][j] < t) {
              t = N[i + k][j];
            }
            if (i + k >= n) {
              flag = false;
              break;
            }
          }
          if (flag && res < t) {
            res = t;
          }
        }
      }
    }
    cout << res << endl;
  }

  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  bool field[1000][1000] = {false};
  while (cin >> n, n) {
    cin.ignore();
    for (int i = 0; i < n; i++) {
      string l;
      getline(cin, l);
      for (int j = 0; j < n; j++) {
        if (l[j] == '*') {
          field[j][i] = 1;
        } else if (l[j] == '.') {
          field[j][i] = 0;
        }
      }
    }
    int dp[1000][1000] = {0};
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (field[j][i] == 0) {
          if (i == 0 || j == 0) {
            dp[j][i] = 1;
          } else {
            dp[j][i] =
                min(min(dp[j - 1][i], dp[j][i - 1]), dp[j - 1][i - 1]) + 1;
          }
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dp[i][j] > ans) {
          ans = dp[i][j];
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  bool field[100][100] = {false};
  while (cin >> n, n) {
    cin.ignore();
    for (int i = 0; i < n; i++) {
      string l;
      getline(cin, l);
      for (int j = 0; j < n; j++) {
        if (l[j] == '*') {
          field[j][i] = 1;
        } else if (l[j] == '.') {
          field[j][i] = 0;
        }
      }
    }
    int dp[100][100] = {0};
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (field[j][i] == 0) {
          if (i == 0 || j == 0) {
            dp[j][i] = 1;
          } else {
            dp[j][i] =
                min(min(dp[j - 1][i], dp[j][i - 1]), dp[j - 1][i - 1]) + 1;
          }
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dp[i][j] > ans) {
          ans = dp[i][j];
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

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

long long int side[1002][1002], ver[1002][1002];

int main() {

  string input, s;

  long long int n;

  while (true) {

    cin >> n;

    if (n == 0)
      break;

    vector<string> map;
    s = "**";
    for (long long int i = 0; i < n; i++) {
      s += "*";
    }
    map.push_back(s);
    for (long long int i = 0; i < n; i++) {
      cin >> input;
      input = "*" + input + "*";
      map.push_back(input);
    }
    map.push_back(s);
    for (long long int i = 1; i <= n; i++) {
      long long int cnt_s = 0;
      long long int cnt_v = 0;
      for (long long int j = 1; j <= n; j++) {
        if (map[i][j] == '*') {
          cnt_s = 0;
        } else {
          cnt_s++;
        }
        side[i][j] = cnt_s;
        if (map[j][i] == '*') {
          cnt_v = 0;
        } else {
          cnt_v++;
        }
        ver[j][i] = cnt_v;
      }
    }
    long long int ans = 0;
    long long int x, y;
    for (long long int i = 0; i < 2 * n - 1; i++) {
      if (i < n) {
        x = 1;
        y = n - i;
      } else {
        x = i - (n - 2);
        y = 1;
      }
      long long int cnt = 0;
      while (true) {
        if (side[y][x] > cnt && ver[y][x] > cnt) {
          cnt++;
        } else {
          ans = max(ans, cnt);
          cnt = min(side[y][x], ver[y][x]);
        }
        x++;
        y++;
        if (x > n || y > n)
          break;
      }
      ans = max(ans, cnt);
    }

    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

long long int side[1002][1002], ver[1002][1002];

int main() {

  string input, s;

  long long int n;

  while (true) {

    cin >> n;

    if (n == 0)
      break;

    vector<string> map;
    s = "**";
    for (long long int i = 0; i < n; i++) {
      s += "*";
    }
    map.push_back(s);
    for (long long int i = 0; i < n; i++) {
      cin >> input;
      input = "*" + input + "*";
      map.push_back(input);
    }
    map.push_back(s);
    for (long long int i = 1; i <= n; i++) {
      long long int cnt_s = 0;
      long long int cnt_v = 0;
      for (long long int j = 1; j <= n; j++) {
        if (map[i][j] == '*') {
          cnt_s = 0;
        } else {
          cnt_s++;
        }
        side[i][j] = cnt_s;
        if (map[j][i] == '*') {
          cnt_v = 0;
        } else {
          cnt_v++;
        }
        ver[j][i] = cnt_v;
      }
    }
    long long int ans = 0;
    for (long long int i = 1; i <= n; i++) {
      for (long long int j = 1; j <= n; j++) {
        if (map[j][i] == '.') {
          long long int cnt = 1;
          while (true) {
            if (side[j + cnt][i + cnt] > cnt && ver[j + cnt][i + cnt] > cnt) {
              cnt++;
              continue;
            }
            break;
          }
          ans = max(ans, cnt);
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Runtime Error

// syakyo

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

using namespace std;

#define loop(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, b) loop(i, 0, b)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;

int main() {
  int n;
  while (cin >> n, n) {
    vvb G(n + 1, vb(n + 1));
    rep(i, n) rep(j, n) {
      char c;
      cin >> c;
      G[i + 1][j + 1] = c == '.';
    }

    vvi dp(n + 1, vi(n + 1));
    int ans = 0;
    loop(i, 1, n + 1) loop(j, 1, n + 1) if (G[i][j]) {
      dp[i][j] = min({dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]}) + 1;
      ans = max(ans, dp[i][j]);
    }
    cout << ans << endl;
  }
}

Error: -11

Fixed submission:

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

using namespace std;

#define loop(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, b) loop(i, 0, b)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;

int main() {
  int n;
  cin >> n;
  vvb G(n);
  rep(i, n) rep(j, n) {
    char c;
    cin >> c;
    G[i][j] = c == '.';
  }

  vvi dp(n + 1, vi(n + 1));
  int ans = 0;
  loop(i, 1, n + 1) loop(j, 1, n + 1) if (G[i + 1][j + 1]) {
    dp[i][j] = min({dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]}) + 1;
    ans = max(ans, dp[i][j]);
  }
  cout << ans << endl;
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  const int smax = 1000;
  string s[smax];
  while (cin >> n) {
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    int c = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        int count = 0;
        if (s[i][j] == '.') {
          int m = min(n - i, n - j);
          int k = 1;
          while (k < m) {
            int a = 0, b = 0;
            while (a < k) {
              if (s[i + k][j + a] == '*')
                break;
              a++;
            }
            while (b < k) {
              if (s[i + b][j + k] == '*')
                break;
              b++;
            }
            if ((a != k || b != k) || s[i + k][j + k] == '*')
              break;
            k++;
          }
          c = max(c, k);
        }
      }
    }
    cout << c << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

bool find_s(string s[1000], int i, int n) {
  for (int j = 0; j <= n - i; j++) {
    for (int k = 0; k <= n - i; k++) {
      int count = 0;
      if (s[j][k] == '.')
        for (int l = 0; l < i; l++) {
          int m = 0;
          for (; m < i; m++) {
            if (s[j + l][k + m] == '*')
              break;
            if (l == i - 1 && m == i - 1)
              return true;
          }
          if (s[j + l][k + m] == '*')
            break;
        }
    }
  }
  return false;
}

int main() {
  int n;
  const int max = 1000;
  string s[max];
  while (cin >> n) {
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    int c = 0;
    for (int i = n; i > 0; i--) {
      if (find_s(s, i, n)) {
        c = i;
        break;
      }
    }
    cout << c << endl;
  }
  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>

#define INF 2100000000

using namespace std;

int minix(int a, int b, int c) {
  if (b >= a && c >= a) {
    return a;
  }
  if (a >= b && c >= b) {
    return b;
  }
  if (b >= c && a >= c) {
    return c;
  }
}

int main() {
  int n;
  int masu[1002][1002];
  int ura[1002][1002];
  char str[1002];
  while (1) {
    for (int i = 0; i <= 1001; i++) {
      for (int j = 0; j <= 1001; j++) {
        masu[i][j] = 0;
      }
    }
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%s", str);
      for (int j = 1; j <= n; j++) {
        if (str[j - 1] == '.') {
          ura[i][j] = 0;
        } else {
          ura[i][j] = 1;
        }
      }
    }

    int maxi = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (ura[i][j] == 0) {
          masu[i][j] =
              minix(masu[i - 1][j], masu[i][j - 1], masu[i - 1][j - 1]) + 1;
          maxi = max(masu[i][j], maxi);
        }
      }
    }

    printf("%d\\n", maxi);
  }
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>

#define INF 2100000000

using namespace std;

int minix(int a, int b, int c) {
  if (b >= a && c >= a) {
    return a;
  }
  if (a >= b && c >= b) {
    return b;
  }
  if (b >= c && a >= c) {
    return c;
  }
}

int main() {
  int n;
  int masu[102][102];
  int ura[102][102];
  char str[1002];
  while (1) {
    for (int i = 0; i <= 101; i++) {
      for (int j = 0; j <= 101; j++) {
        masu[i][j] = 0;
      }
    }
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%s", str);
      for (int j = 1; j <= n; j++) {
        if (str[j - 1] == '.') {
          ura[i][j] = 0;
        } else {
          ura[i][j] = 1;
        }
      }
    }

    int maxi = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (ura[i][j] == 0) {
          masu[i][j] =
              minix(masu[i - 1][j], masu[i][j - 1], masu[i - 1][j - 1]) + 1;
          maxi = max(masu[i][j], maxi);
        }
      }
    }

    printf("%d\\n", maxi);
  }
}