alexjercan/bugnet huggingface dataset:
Problem p00090 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>

int n;
struct point {
  double x, y;
  point() {}
  point(double xx, double yy) {
    x = xx;
    y = yy;
  }

  point operator+(point p) { return point(x + p.x, y + p.y); }
  point operator/(double d) { return point(x / d, y / d); }
};

point p[101];

int main(void) {
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      scanf("%lf,%lf", &p[i].x, &p[i].y);
    }
    if (n == 1)
      printf("1\\n");
    else {
      int res = 1;
      for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
          point mid = (p[i] + p[j]) / 2.0;
          double ang = atan2(mid.y - p[i].y, mid.x - p[i].x);
          double len = (p[i].x - mid.x) * (p[i].x - mid.x) +
                       (p[i].y - mid.y) * (p[i].y - mid.y);
          double np = sqrt(1 - len);
          point pp = mid + point(np * cos(ang + M_PI / 2.0),
                                 np * sin(ang + M_PI / 2.0));
          int cnt = 2;
          for (int k = 0; k < n; k++) {
            if (k == i || k == j)
              continue;
            if ((pp.x - p[k].x) * (pp.x - p[k].x) +
                    (pp.y - p[k].y) * (pp.y - p[k].y) <=
                1.0)
              cnt++;
          }
          res = std::max(res, cnt);
          pp = mid +
               point(np * cos(ang - M_PI / 2.0), np * sin(ang - M_PI / 2.0));
          cnt = 2;
          for (int k = 0; k < n; k++) {
            if (k == i || k == j)
              continue;
            if ((pp.x - p[k].x) * (pp.x - p[k].x) +
                    (pp.y - p[k].y) * (pp.y - p[k].y) <=
                1.0)
              cnt++;
          }
          res = std::max(res, cnt);
        }
      }
      printf("%d\\n", res);
    }
  }
  return 0;
}

Error: -11

Fixed submission:

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

int n;
double x[101], y[101];
int count[101];
int main(void) {
  while (1) {
    memset(count, 0, sizeof(count));
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      scanf("%lf,%lf", x[i], y[i]);
      for (int j = 0; j < i; j++) {
        if (sqrt(pow(fabs(x[i] - x[j]), 2) + pow(fabs(y[i] - y[j]), 2)) < 2) {
          count[i]++;
          count[j]++;
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      ans = max(ans, count[i]);
    }
    ans++;
    cout << ans << endl;
  }
  return 0;
}
Problem p00090 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
struct P {
  double x, y;
};
#define rep(i, n) for (int i = 0; i < n; i++)
const double EPS = 1e-15;

vector<P> cross(P a, P b) {
  vector<P> ret;

  double x = a.x - b.x, y = a.y - b.y;
  double L = x * x + y * y;
  if (L > 4.0)
    return ret;

  L = sqrt(L);
  double C = atan2(b.y - a.y, b.x - a.x);
  double alpha = acos(L / 2);

  P r1, r2;
  r1.x = a.x + cos(C + alpha), r1.y = a.y + sin(C + alpha);
  r2.x = a.x + cos(C - alpha), r2.y = a.y + sin(C - alpha);

  ret.push_back(r1), ret.push_back(r2);
  return ret;
}

bool check(P cir, P pt) {
  cir.x -= pt.x, cir.y -= pt.y;
  return (cir.x * cir.x + cir.y * cir.y) <= 1.0 + EPS;
}

int main() {
  int n;
  while (scanf("%d", &n) && n) {
    int ret = 1;
    vector<P> data(n);
    rep(i, n) scanf("%lf,%lf\\n", &data[i].x, &data[i].y);

    vector<P> search;
    rep(i, n) {
      for (int j = i + 1; j < n; j++) {
        vector<P> get = cross(data[i], data[j]);
        rep(k, get.size()) { search.push_back(get[k]); }
      }
    }
    rep(i, search.size()) {
      int count = 0;
      rep(j, n) count += check(data[j], search[i]);
      ret = max(ret, count);
    }
    cout << ret << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
int ans = 0;
struct Rect {
  double x, y, size;
  int count;
  Rect(double x = 0, double y = 0, double size = 0, int count = 0)
      : x(x), y(y), size(size), count(count) {}
};
bool operator<(const Rect &a, const Rect &b) { return a.count < b.count; }
struct Point {
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}
};
priority_queue<Rect> que;
int N;
vector<Point> point;
const double EPS = 1e-8;
#define p2(x) ((x) * (x))
void makerect(double x, double y, double size) {
  int cnt = 0, cnt2 = 0;
  x += size * .5;
  y += size * .5;
  REP(i, N) {
    if (p2(point[i].x - x) + p2(point[i].y - y) <= p2(0.70711 * size + 1 + EPS))
      cnt++;
    if (p2(point[i].x - x) + p2(point[i].y - y) <= 1.00 + EPS)
      cnt2++;
  }
  x -= size * .5;
  y -= size * .5;

  ans = max(ans, cnt2);
  if (cnt > ans)
    que.push(Rect(x, y, size, cnt));
}
void solve() {
  que = priority_queue<Rect>();
  que.push(Rect(0, 0, 10.0, N));
  while (!que.empty()) {
    Rect t = que.top();
    que.pop();
    if (t.count <= ans) {
      break;
    }
    (makerect(t.x, t.y, t.size * .5));
    (makerect(t.x + t.size * .5, t.y, t.size * .5));
    (makerect(t.x, t.y + t.size * .5, t.size * .5));
    (makerect(t.x + t.size * .5, t.y + t.size * .5, t.size * .5));
  }
}
int main() {
  for (; cin >> N, N;) {
    point = vector<Point>(N);
    REP(i, N) { cin >> point[i].x >> point[i].y; }
    ans = 1;
    solve();
    cout << ans << endl;
  }
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>

using namespace std;
typedef long long int lint;

int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}

int solve(int n) {
  int ret = 0;

  int **a = new int *[n + 1];
  for (int i = 0; i <= n; i++) {
    a[i] = new int[n + 1];
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      a[i][j] = 0;
    }
  }

  string buf;

  for (int i = 0; i < n; i++) {
    cin >> buf;
    for (int j = 0; j < n; j++) {
      if (buf[j] != '*') {
        int ni = i + 1;
        int nj = j + 1;
        a[ni][nj] =
            min(a[ni - 1][nj - 1], min(a[ni][nj - 1], a[ni - 1][nj])) + 1;
        if (ret < a[ni][nj])
          ret = a[ni][nj];
      }
    }
  }

  for (int i = 0; i <= n; i++) {
    delete[] a[i];
  }
  delete[] a;

  return ret;
}

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    cout << solve(n) << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>

#define int64 long long int
using namespace std;

int square_search(string *, int);
int size(string *, int, int, int);

int main() {
  int i, n;
  string *map;

  while (1) {
    cin >> n;
    if (n == 0)
      break;

    map = new string[n];

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

    cout << square_search(map, n) << endl;

    delete[] map;
  }

  return 0;
}

int square_search(string *map, int n) {
  int s, max = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (map[i][j] == '.') {
        s = size(map, i, j, n);
        if (max < s)
          max = s;
      }
    }
  }
  return max;
}

int size(string *map, int i, int j, int n) {
  int k = 1;
  while (i + k < n && j + k < n) {
    for (int l = 0; l <= k; l++) {
      if (map[i + l][j + k] == '*')
        return k;
      if (map[i + k][j + l] == '*')
        return k;
    }
    k++;
  }
  return k;
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, k, n) for (int i = (k); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) begin(a), end(a)
#define MS(m, v) memset(m, v, sizeof(m))
#define D10 fixed << setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge {
  int from, to, cost;
  bool operator<(const edge &e) const { return cost < e.cost; }
  bool operator>(const edge &e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int n;
vector<string> fld;
int cnt[1005][1005];

bool search(int m) {
  REP(i, n - m + 1) REP(j, n - m + 1) {
    REP(k, m) {
      if (cnt[i + k][j] < m)
        goto next;
    }

    return true;
  next:;
  }
  return false;
}

int main() {
  while (cin >> n, n) {
    MS(cnt, 0);
    fld.resize(n);
    REP(i, n) {
      cin >> fld[i];
      cnt[i][n] = 0;
      REP(j, n) {
        cnt[i][n - j - 1] = (fld[i][n - j - 1] == '*' ? 0 : cnt[i][n - j] + 1);
      }
    }
    int lb = 0, ub = 2 * n;
    while (ub - lb > 1) {
      int mid = (ub + lb) / 2;
      if (search(mid))
        lb = mid;
      else
        ub = mid;
    }
    cout << lb << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, k, n) for (int i = (k); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) begin(a), end(a)
#define MS(m, v) memset(m, v, sizeof(m))
#define D10 fixed << setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge {
  int from, to, cost;
  bool operator<(const edge &e) const { return cost < e.cost; }
  bool operator>(const edge &e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int n;
vector<string> fld;

bool search(int m) {
  REP(i, n - m + 1) REP(j, n - m + 1) {
    REP(k, m) REP(l, m) {
      if (fld[i + k][j + l] == '*')
        goto next;
    }

    return true;
  next:;
  }
  return false;
}

int main() {
  while (cin >> n, n) {
    fld.resize(n);
    REP(i, n) cin >> fld[i];
    int lb = 0, ub = 2 * n;
    while (ub - lb > 1) {
      int mid = (ub + lb) / 2;
      if (search(mid))
        lb = mid;
      else
        ub = mid;
    }
    cout << lb << endl;
  }
  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

using namespace std;

int n;
char field[1000][1000];

int dp[1000][1000];

void solve() {
  fill(dp[0], dp[1000], 0);
  for (int i = 0; i < n; i++) {
    if (field[0][i] == '.')
      dp[0][i] = 1;
    if (field[i][0] == '.')
      dp[i][0] = 1;
  }

  int max = 0;
  for (int y = 1; y < n; y++)
    for (int x = 1; x < n; x++) {
      if (field[y][x] == '*') {
        dp[y][x] = 0;
        continue;
      }
      int min = dp[y - 1][x - 1];
      if (min > dp[y][x - 1])
        min = dp[y][x - 1];
      if (min > dp[y - 1][x])
        min = dp[y - 1][x];
      dp[y][x] = min + 1;
      if (dp[y][x] > max)
        max = dp[y][x];
    }

  cout << max << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  while (cin >> n, n) {
    for (int y = 0; y < n; y++)
      for (int x = 0; x < n; x++)
        cin >> field[y][x];
    solve();
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int n;
char field[1000][1000];

inline bool checksub(int x, int y, int m) {
  for (int ty = y; ty < y + m; ty++)
    for (int tx = x; tx < x + m; tx++)
      if (field[ty][tx] == '*')
        return false;
  return true;
}

inline bool check(int m) {
  for (int y = 0; y < n - m + 1; y++)
    for (int x = 0; x < n - m + 1; x++)
      if (checksub(x, y, m))
        return true;
  return false;
}

void solve() {
  int left, right;
  left = 0;
  right = n + 1;
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (check(mid))
      left = mid;
    else
      right = mid;
  }
  cout << left << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  while (cin >> n, n) {
    for (int y = 0; y < n; y++)
      for (int x = 0; x < n; x++)
        cin >> field[y][x];
    solve();
  }
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <string>

int main() {
  int n;
  while (std::cin >> n) {
    if (n == 0)
      break;

    int dp[n][n], ans = 0;

    for (int i = 0; i < n; i++) {
      std::string str;
      std::cin >> str;

      for (int j = 0; j < n; j++) {
        if (str[j] == '*') {
          dp[i][j] = 0;
        } else {
          if (i > 0 && j > 0) {
            dp[i][j] = std::min(dp[i - 1][j],
                                std::min(dp[i][j - 1], dp[i - 1][j - 1])) +
                       1;
          } else {
            dp[i][j] = 1;
          }
          ans = std::max(ans, dp[i][j]);
        }
      }
    }

    std::cout << ans << std::endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>

int main() {
  int n;
  while (std::cin >> n) {
    if (n == 0)
      break;

    int map[n + 1][n + 1], sum[n + 1][n + 1];
    for (int i = 0; i <= n; i++) {
      std::fill(map[i], map[i] + n + 1, 0);
      std::fill(sum[i], sum[i] + n + 1, 0);
    }

    for (int i = 1; i <= n; i++) {
      std::string str;
      std::cin >> str;

      for (int j = 1; j <= n; j++) {
        if (str[j - 1] == '*') {
          map[i][j] = 0;
        } else {
          map[i][j] = 1;
        }
      }
    }

    sum[1][1] = map[1][1];
    for (int i = 2; i <= n; i++) {
      sum[i][1] = sum[i - 1][1] + map[i][1];
      sum[1][i] = sum[1][i - 1] + map[1][i];
    }

    for (int i = 2; i <= n; i++) {
      for (int j = 2; j <= n; j++) {
        sum[i][j] =
            map[i][j] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
      }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        for (int k = i; k <= n; k++) {
          int tmp =
              sum[j][k] - sum[j - i][k] - sum[j][k - i] + sum[j - i][k - i];
          if (tmp == i * i && i > ans) {
            ans = i;
          }
        }
      }
    }

    std::cout << ans << std::endl;
  }
  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <climits>
#include <cstdio>
#include <iostream>
using namespace std;

char fld[1001][1001];
int dp[1001][1001];

int main() {
  int N;
  while (cin >> N, N) {
    int ans = 0;
    for (int i = 0; i <= N; i++) {
      for (int j = 0; j <= N; j++) {
        if (i == 0 || j == 0) {
          dp[i][j] = 0;
          continue;
        }
        cin >> fld[i][j];
        if (fld[i][j] != '.') {
          dp[i][j] = 0;
          continue;
        }
        dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
        if (fld[i - dp[i][j]][j - dp[i][j]] == '.')
          ans = max(ans, ++dp[i][j]);
        else
          dp[i][j] = max(dp[i][j], 1);
      }
    }
    printf("%d\\n", ans);
  }
  return 0;
}

Error: -11

Fixed submission:

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

char stage[1000][1000];
int main() {
  int n;
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      cin >> stage[i];
    }

    int ny, nx, ans = 0;
    int situ_y[2] = {0, 1}, situ_x[2] = {1, 0};
    for (int y = 0; y < n; y++) {
      for (int x = 0; x < n; x++) {
        if (stage[y][x] != 0 && stage[y][x] != '*') {
          int s[2] = {}, mini = 1000;
          for (int j = 0; j < 2; j++) {
            bool flag = false;
            for (int i = 1;; i++) {
              for (int k = i; k >= 0; k--) {
                ny = y + situ_y[j] * i + situ_x[j] * k;
                nx = x + situ_x[j] * i + situ_y[j] * k;
                if (ny < 0 || n <= ny || nx < 0 || n <= nx ||
                    stage[ny][nx] == '*') {
                  flag = true;
                  if (i > s[j]) {
                    s[j] = i;
                  }
                }
                if (flag) {
                  if (k == i)
                    k--;
                  for (; k >= 0; k--) {
                    for (int l = 0; l < k /*&& k != i*/; l++) {
                      ny = y + situ_x[j] * k + situ_y[j] * l;
                      nx = x + situ_y[j] * k + situ_x[j] * l;
                      stage[ny][nx] = 0;
                    }
                  }
                  break;
                }
              }
            }
            if (flag)
              break;
          }
          for (int i = 0; i < 2; i++) {
            if (mini > s[i])
              mini = s[i];
          }
          if (mini > ans)
            ans = mini;
        }
      }
    }
    printf("%d\\n", ans);
  }
  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int sum[1000][1000] = {0};

int main() {
  int H, top = 0;
  string str;

  while (cin >> H) {
    getline(cin, str); // kill \\n
    string field[1000] = {""};
    if (H == 0)
      break;

    for (int i = 0; i < H; i++) { // get field for string
      getline(cin, str);
      field[i] = str;
    }
    if (field[0].substr(0, 1) == ".") {
      sum[0][0] = 1;
    } else {
      sum[0][0] = 0;
    }
    for (int j = 1; j < H; j++) {
      if (field[0].substr(j, 1) == ".") {
        sum[0][j] = 1 + sum[0][j - 1];
      } else {
        sum[0][j] = sum[0][j - 1];
      }
    }

    for (int i = 1; i < H; i++) {
      if (field[i].substr(0, 1) == ".") {
        sum[i][0] = 1 + sum[i - 1][0];
      } else {
        sum[i][0] = sum[i - 1][0];
      }
    }

    for (int i = 1; i < H; i++) {
      for (int j = 1; j < H; j++) {
        if (field[i].substr(j, 1) == ".") {
          sum[i][j] = 1 + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
        } else {
          sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
        }
      }
    }
    int S;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < H; j++) {
        if (field[i].substr(j, 1) == ".") {
          for (int k = 1; k <= min(i + 1, j + 1); k++) {
            if (i != H - 1 || j != H - 1 || k != min(i + 1, j + 1)) {
              S = sum[i][j] - sum[i - k][j] - sum[i][j - k] + sum[i - k][j - k];
            } else {
              S = sum[i][j];
            }

            if (S == k * k) {
              top = max(top, k);
            } else {
              break;
            }
          }
        }
      }
    }

    cout << top << endl;
    top = 0;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int H, x, top = 0;
  string str;
  while (cin >> H) {
    getline(cin, str); // kill \\n
    string field[1000] = {""};
    if (H == 0)
      break;

    for (int i = 0; i < H; i++) { // get field for string
      getline(cin, str);
      field[i] = str;
    }

    for (int i = 0; i < H; i++) { // calc
      for (int j = 0; j < H; j++) {

        if (field[i].substr(j, 1) == ".") {
          x = 1;
          bool r = true;

          for (int k = 0; k < min(top, H - j); k++) {
            if (field[i].substr(j + k, 1) != ".") {
              r = false;
            }
          }
          while (r) {
            if (H - 1 < i + x || H - 1 < j + x)
              break;
            for (int i1 = 0; i1 <= x; i1++) {
              if (field[i + x].substr(j + i1, 1) != ".") {
                r = false;
                break;
              }
            }
            for (int i1 = 0; i1 <= x; i1++) {
              if (field[i + i1].substr(j + x, 1) != ".") {
                r = false;
                break;
              }
            }
            if (r) {
              x++;
            }
          }
        } else {
          x = 0;
        }
        top = max(x, top);
      }
    }
    cout << top << endl;
    top = 0;
  }
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define mp make_pair

template <class T> void pv(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << *i << " ";
  cout << endl;
}
template <class T> void chmin(T &t, T f) {
  if (t > f)
    t = f;
}
template <class T> void chmax(T &t, T f) {
  if (t < f)
    t = f;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

int m[1010][1010];
string s[1010];

int main() {
  int n;
  while (n = in()) {
    int i;
    for (i = 0; i < n; i++) {
      cin >> s[i];
    }
    for (i = 0; i < n; i++) {
      if (s[0][i] == '.')
        m[0][i] = 1;
      else
        m[0][i] = 0;
      if (s[i][0] == '.')
        m[i][0] = 1;
      else
        m[i][0] = 0;
    }
    int j;
    for (i = 1; i < n; i++) {
      for (j = 1; j < n; j++) {
        if (s[i][j] == '.')
          m[i][j] = min(min(m[i - 1][j - 1], m[i - 1][j]), m[i][j - 1]) + 1;
        else
          m[i][j] = 0;
      }
    }
    int mx = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        // cout<<m[i][j];
        chmax(mx, m[i][j]);
      }
      // cout<<endl;
    }
    cout << mx << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define mp make_pair

template <class T> void pv(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << *i << " ";
  cout << endl;
}
template <class T> void chmin(T &t, T f) {
  if (t > f)
    t = f;
}
template <class T> void chmax(T &t, T f) {
  if (t < f)
    t = f;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

string m[1010];

int n;

bool f(int i) {
  int x, y;
  for (y = 0; y < n; y++) {
    for (x = 0; x < n; x++) {
      int xx, yy;
      bool flag = true;
      for (yy = 0; yy < i; yy++) {
        for (xx = 0; xx < i; xx++) {
          if (yy + y >= n || xx + x >= n) {
            flag = false;
            break;
          }
          if (m[yy + y][xx + x] == '*') {
            flag = false;
            break;
          }
        }
      }
      if (flag)
        return true;
    }
  }
  return false;
}

int main() {
  while (n = in()) {
    int i;
    for (i = 0; i < n; i++) {
      cin >> m[i];
    }
    int a = 0, b = n;
    while (a != b) {
      if (f((a + b + 1) / 2)) {
        a = (a + b + 1) / 2;
      } else {
        b = (a + b + 1) / 2 - 1;
      }
    }
    cout << a << endl;
  }
  return 0;
}