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

// C++11

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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)

const int MAXN = 1000;
int n;
int num[MAXN][MAXN];
bool mat[MAXN][MAXN];

int solve(void) {
  int lmax = 0;
  REP(i, n) {
    REP(j, n) {
      if (i == 0 || j == 0)
        num[i][j] = (mat[i][j]) ? 1 : 0;
      else
        num[i][j] =
            (mat[i][j])
                ? min(num[i - 1][j - 1], min(num[i - 1][j], num[i][j - 1])) + 1
                : 0;
      if (num[i][j] > lmax)
        lmax = num[i][j];
    }
  }
  return lmax;
}

int main(void) {
  while (true) {
    // read
    cin >> n;
    if (!n)
      break;
    REP(j, n) {
      string s;
      cin >> s;
      REP(i, n) mat[i][j] = (s[i] == '.') ? true : false;
    }
    // solve and print
    int res = solve();
    cout << res << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

// C++11

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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)

const int MAXN = 1000;
int n;
bool mat[MAXN][MAXN];

int solve(void) {
  // all filled
  bool empty;
  empty = false;
  REP(i, n) REP(j, n) empty = empty || mat[i][j];
  if (!empty)
    return 0;
  // check for all
  int lmax = 0;
  REP(i, n) {
    REP(j, n) {
      if (!mat[i][j])
        continue;
      int l0 = min(n - i, n - j);
      int l1 = l0;
      REP(l, l0) {
        REP(m, l + 1) {
          if ((!mat[i + l][j + m]) || (!mat[i + m][j + l])) {
            l1 = l;
            goto outofloop;
          }
        }
      }
    outofloop:
      if (lmax < l1)
        lmax = l1;
    }
  }
  return lmax;
}

int main(void) {
  while (true) {
    // read
    cin >> n;
    if (!n)
      break;
    REP(j, n) {
      string s;
      cin >> s;
      REP(i, n) mat[i][j] = (s[i] == '.') ? true : false;
    }
    // solve and print
    int res = solve();
    cout << res << endl;
  }
  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Runtime Error

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

int dp[1002][1002];

int main() {
  int n;
  while (scanf("%d", &n), n) {
    int ret = 0;
    char line[1001];
    for (int i = 1; i <= n; ++i) {
      scanf("%s", line);
      for (int j = 0; j < n; ++j) {
        if (line[j] == '.') {
          dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
          ret = max(ret, dp[i][j]);
        } else {
          dp[i][j] = 0;
        }
      }
    }
    printf("%d\\n", ret);
  }
  return 0;
}

Error: 0

Fixed submission:

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

int dp[1002][1002];

int main() {
  int n;
  while (scanf("%d", &n), n) {
    int ret = 0;
    char line[101];
    for (int i = 1; i <= n; ++i) {
      scanf("%s", line);
      for (int j = 0; j < n; ++j) {
        if (line[j] == '.') {
          dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
          ret = max(ret, dp[i][j]);
        } else {
          dp[i][j] = 0;
        }
      }
    }
    printf("%d\\n", ret);
  }
  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int n, ans = 0;
  int dp[1100][1100];
  char field;
  while (scanf("%d", &n), n) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        scanf(" %c", &field);
        dp[j + 1][i + 1] = 0;
        if (field == '*')
          dp[j + 1][i + 1] = -1;
      }
    for (int i = 1; i < n + 1; i++) {
      for (int j = 1; j < n + 1; j++) {
        if (dp[j][i] == -1)
          ;
        else if (j == 1 || i == 1)
          dp[j][i] = 1;
        else
          dp[j][i] = max(
              1, min(dp[j - 1][i - 1], min(dp[j - 1][i], dp[j][i - 1])) + 1);
        ans = max(ans, dp[j][i]);
      }
    }
    /*for(int i = 1; i < n + 1; i++)
    {
        for(int j = 1; j < n + 1; j++)
        {
            printf("%2d",dp[j][i]);
        }
        printf("\\n");
    }*/
    printf("%d\\n", ans);
    ans = 0;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int n, ans = 0;
  int dp[110][110];
  char field;
  while (scanf("%d", &n), n) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        scanf(" %c", &field);
        dp[j + 1][i + 1] = 0;
        if (field == '*')
          dp[j + 1][i + 1] = -1;
      }
    for (int i = 1; i < n + 1; i++) {
      for (int j = 1; j < n + 1; j++) {
        if (dp[j][i] == -1)
          ;
        else if (j == 1 || i == 1)
          dp[j][i] = 1;
        else
          dp[j][i] = max(
              1, min(dp[j - 1][i - 1], min(dp[j - 1][i], dp[j][i - 1])) + 1);
        ans = max(ans, dp[j][i]);
      }
    }
    /*for(int i = 1; i < n + 1; i++)
    {
        for(int j = 1; j < n + 1; j++)
        {
            printf("%2d",dp[j][i]);
        }
        printf("\\n");
    }*/
    printf("%d\\n", ans);
    ans = 0;
  }
  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, int> pii;

#define rep(i, j) for (int i = 0; i < (j); i++)
#define reps(i, j, k) for (int i = j; i <= k; i++)
#define in(i, j, k) ((i) >= (j) && (i) <= (k))

int main() {
  char s[1001];
  int n, r, m;
  int w[1000], h[1000], a[2][1000];
  for (;;) {
    scanf("%d", &n);
    if (!n)
      break;
    rep(i, 1000) {
      rep(j, 2) a[j][i] = 0;
      w[i] = h[i] = 0;
    }
    r = 0;
    rep(i, n) {
      scanf("%s", s);
      rep(j, n) {
        if (s[j] == '.') {
          a[i % 2][j] = 1;
          if (j > 0) {
            w[j] = w[j - 1] + 1;
            a[i % 2][j] += min(a[(1 + i) % 2][j - 1], min(w[j - 1], h[j]));
          } else
            w[j]++;
          h[j]++;
          r = max(r, a[i % 2][j]);
        } else
          a[i % 2][j] = h[j] = w[j] = 0;
      }
    }
    printf("%d\\n", r);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, int> pii;

#define rep(i, j) for (int i = 0; i < (j); i++)
#define reps(i, j, k) for (int i = j; i <= k; i++)
#define in(i, j, k) ((i) >= (j) && (i) <= (k))

int main() {
  char s[1001];
  int n, r, m;
  int a[2][1000];
  for (;;) {
    scanf("%d", &n);
    if (!n)
      break;
    rep(i, 1000) rep(j, 2) a[j][i] = 0;
    r = 0;
    rep(i, n) {
      scanf("%s", s);
      rep(j, n) {
        if (s[j] == '.') {
          m = a[i % 2][j] = a[(i + 1) % 2][j] + 1;
          for (int k = j; k >= 0 && a[i % 2][k] > 0; k--) {
            m = min(m, a[i % 2][k]);
            r = max(r, min(m, j - k + 1));
          }
        } else
          a[i % 2][j] = 0;
      }
    }
    printf("%d\\n", r);
  }
  return 0;
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int field[1000][1000];
  int n, dp[1000][1000];
  while (cin >> n, n) {
    getchar();
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        char c = getchar();
        if (c == '.')
          field[i][j] = 1;
        else
          field[i][j] = 0;
        dp[i][j] = 0;
      }
      getchar();
    }
    for (int i = 0; i < n; i++) {
      dp[i][0] = field[i][0];
      dp[0][i] = field[0][i];
    }
    int ma = 0;
    for (int i = 1; i < n; i++) {
      for (int j = 1; j < n; j++) {
        if (!field[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;
        ma = max(ma, dp[i][j]);
      }
    }
    cout << ma << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <stdio.h>
using namespace std;

int issquare(int, int, int, int);
int field[1000][1000];

int main() {
  int i, j, n, ans;
  char map;
  while (1) {
    ans = 0;
    scanf("%d", &n);
    if (!n)
      break;
    getchar();
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        map = getchar();
        if (map == '.')
          field[i][j] = 0;
        else
          field[i][j] = 1;
      }
      getchar();
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (field[i][j] == 0)
          ans = max(ans, issquare(i, j, n, ans));
      }
    }
    printf("%d\\n", ans);
  }
  return 0;
}

int issquare(int x, int y, int n, int ans) {
  int i, j;
  for (i = 0; i < ans; i++) {
    for (j = 0; j < ans; j++) {
      if (x + i >= n || y + j >= n || field[x + i][y + j] != 0)
        return i - 1;
    }
  }
  for (i = ans;; i++) {
    for (j = 0; j < i; j++) {
      if (x + j >= n || y + i - 1 >= n || field[x + j][y + i - 1] != 0)
        return i - 1;
    }
    for (j = 0; j < i; j++) {
      if (x + i - 1 >= n || y + j >= n || field[x + i - 1][y + j] != 0)
        return i - 1;
    }
  }
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 100000;
int cnt[1000][1000];
int main() {
  int n;
  char fld[1000][1000];
  while (scanf("%d", &n) && n) {
    memset(cnt, 0, sizeof(cnt));
    REP(i, n) {
      scanf("%s", fld[i]);
      REP(j, n) if (fld[i][j] == '*') cnt[i][j]++;
    }
    // REP(i,n){REP(j,n)cout<<cnt[j][i];cout<<endl;}
    REP(i, n) REP(j, n) {
      if (i != 0)
        cnt[j][i] += cnt[j][i - 1];
      if (j != 0)
        cnt[j][i] += cnt[j - 1][i];
      if (i != 0 && j != 0)
        cnt[j][i] -= cnt[j - 1][i - 1];
    }
    // REP(i,n){REP(j,n)cout<<cnt[j][i]<<" ";cout<<endl;}
    int ans = 0;
    REP(x, n) REP(y, n) {
      for (int d = ans; d < min(n - x, n - y); d++) {
        int nx = x + d, ny = y + d;
        int c = cnt[ny][nx];
        if (x != 0)
          c -= cnt[ny][x - 1];
        if (y != 0)
          c -= cnt[y - 1][nx];
        if (x != 0 && y != 0)
          c += cnt[y - 1][x - 1];
        if (c == 0 && ans < d + 1) {
          // cout<<x<<" "<<y<<" "<<d+1<<endl;
          ans = d + 1;
        }
      }
    }
    printf("%d\\n", ans);
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 100000;
int cnt[1000][1000];
int main() {
  int n;
  char fld[1000][1000];
  while (scanf("%d", &n) && n) {
    memset(cnt, 0, sizeof(cnt));
    REP(i, n) {
      scanf("%s", fld[i]);
      REP(j, n) if (fld[i][j] == '*') cnt[i][j]++;
    }
    // REP(i,n){REP(j,n)cout<<cnt[j][i];cout<<endl;}
    REP(i, n) REP(j, n) {
      if (i != 0)
        cnt[j][i] += cnt[j][i - 1];
      if (j != 0)
        cnt[j][i] += cnt[j - 1][i];
      if (i != 0 && j != 0)
        cnt[j][i] -= cnt[j - 1][i - 1];
    }
    // REP(i,n){REP(j,n)cout<<cnt[j][i]<<" ";cout<<endl;}
    int ans = 0;
    REP(x, n) REP(y, n) {
      REP(d, min(n - x, n - y)) {
        int nx = x + d, ny = y + d;
        int c = cnt[ny][nx];
        if (x != 0)
          c -= cnt[ny][x - 1];
        if (y != 0)
          c -= cnt[y - 1][nx];
        if (x != 0 && y != 0)
          c += cnt[y - 1][x - 1];
        if (c == 0 && ans < d + 1) {
          // cout<<x<<" "<<y<<" "<<d+1<<endl;
          ans = d + 1;
        }
      }
    }
    printf("%d\\n", ans);
  }
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

using namespace std;

#define NMAX 1000

int main() {

  int n;
  string sqs[NMAX + 1];
  int sqi[NMAX + 1][NMAX + 1];
  int sqw[NMAX + 1][NMAX + 1];
  int max;

  while (1) {

    cin >> n;
    if (n == 0)
      break;

    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        sqi[i][j] = 0;
        sqw[i][j] = 0;
      }
    }

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

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (sqs[i - 1][j - 1] == '.')
          sqi[i][j] = 1;
        else
          sqi[i][j] = 0;
      }
    }

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        sqw[i][j] =
            sqi[j][i] + sqw[i - 1][j] + sqw[i][j - 1] - sqw[i - 1][j - 1];
      }
    }

    max = 0;

    for (int i = 1; i <= n; i++) {
      if (i + max - 1 > n)
        continue;
      for (int j = 1; j <= n; j++) {
        if (j + max - 1 > n)
          continue;
        for (int k = max; i + k <= n && j + k <= n; k++) {
          if ((k + 1) * (k + 1) == sqw[i + k][j + k] - sqw[i + k][j - 1] -
                                       sqw[i - 1][j + k] + sqw[i - 1][j - 1]) {
            if (max < k + 1)
              max = k + 1;
          } else
            break;
        }
      }
    }
    cout << max << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

#define NMAX 1010

int main() {

  int n;
  string sqs[NMAX + 1];
  int sqi[NMAX + 1][NMAX + 1];
  int sqw[NMAX + 1][NMAX + 1];
  int max;
  int mx, mn;
  int c;
  while (1) {

    cin >> n;
    if (n == 0)
      break;

    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        sqi[i][j] = 0;
        sqw[i][j] = 0;
      }
    }

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

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (sqs[i - 1][j - 1] == '.')
          sqi[i][j] = 1;
        else
          sqi[i][j] = 0;
      }
    }

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        sqw[i][j] =
            sqi[j][i] + sqw[i - 1][j] + sqw[i][j - 1] - sqw[i - 1][j - 1];
      }
    }

    max = 0;

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (sqi[i][j] == 0)
          continue;
        if (i > j)
          mx = 10 - i;
        else
          mx = 10 - j;
        mn = 0;
        c = 0;
        while (mx - 1 != mn && mx != mn) {
          int k = (mx + mn) / 2;
          if ((k + 1) * (k + 1) == sqw[i + k][j + k] - sqw[i + k][j - 1] -
                                       sqw[i - 1][j + k] + sqw[i - 1][j - 1]) {
            mn = k;
          } else
            mx = k;
          c++;
          if (c == 0)
            break;
        }
        if (mn + 1 > max && sqi[i][j] != 0)
          max = mn + 1;
      }
    }
    cout << max << endl;
  }
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int dp[1000][1000];
string str[1000];

int serch(int n) {
  int ans = 0;
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (str[i][j] == '*')
        dp[i][j] = 0;
      else {
        if (i > 0 && j > 0)
          dp[i][j] = min(min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1;
        else
          dp[i][j] = 1;
        ans = max(dp[i][j], ans);
      }
    }
  }
  return ans;
}
int main() {
  int n;
  while (cin >> n, n) {
    for (int i = 0; i < n; i++)
      cin >> str[i];
    cout << serch(n) << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
string str[1000];
int serch(int now, int y, int x, int maxe) {
  if (maxe == now + x)
    return 1;
  for (int i = 1;; i++) {
    if (str[y + i][x + now] == '*' || str[y + now][x + i] == '*')
      return 1;
    if (y + i == y + now)
      return serch(now + 1, y, x, maxe) + 1;
  }
}
int main() {
  int n;
  while (cin >> n, n) {
    for (int i = 0; i < n; i++)
      cin >> str[i];
    int ans = 0;
    for (int i = 0; i < n - ans; i++) {
      for (int j = 0; j < n - ans; j++) {
        if (str[i][j] == '.') {
          int kawa = 0;
          for (int k = j + 1, l = i + 1; kawa != 1; k++, l++) {
            if (k - j > ans)
              kawa = 1;
            if (k == n || l == n)
              break;
            if (str[i][k] == '*' || str[l][j] == '*')
              break;
          }
          if (kawa == 1)
            ans = max(serch(1, i, j, n), ans);
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

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

static const int MARGIN = 1;

int main() {
  int n;
  int table[1024][1024];
  vector<string> map;

  while (cin >> n, n) {
    int ans = 0;
    // init;
    for (int i = 0; i < 1024; i++)
      for (int j = 0; j < 1024; j++)
        table[i][j] = 0;
    map.clear();

    // input;
    for (int i = 0; i < n; i++) {
      string tmp;
      cin >> tmp;
      map.push_back(tmp);
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (map[i][j] == '.') {
          int tmp;
          tmp = min(table[i - 1 + MARGIN][j + MARGIN],
                    table[i + MARGIN][j - 1 + MARGIN]);
          if (map[i - tmp][j - tmp] == '.')
            table[i + MARGIN][j + MARGIN] = tmp + 1;
          else
            table[i + MARGIN][j + MARGIN] = tmp;
          if (table[i + MARGIN][j + MARGIN] > ans)
            ans = table[i + MARGIN][j + MARGIN];
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main(void) {
  vector<string> in;
  int n;
  int top, bottom, middle;

  while (cin >> n, n) {
    in.clear();
    for (int i = 0; i < n; i++) {
      string str;
      cin >> str;
      in.push_back(str);
    }

    top = in.size();
    bottom = 0;

    while (top > bottom) {
      bool flag;
      middle = (top + bottom) / 2 + (top + bottom) % 2;

      for (int i = 0; i < n - middle + 1; i++) {
        for (int j = 0; j < n - middle + 1; j++) {
          flag = true;
          for (int k = 0; k < middle; k++) {
            for (int l = 0; l < middle; l++) {
              if (in[i + k][j + l] != '.') {
                k = l = middle;
                flag = false;
              }
            }
          }
          if (flag) {
            bottom = middle;
            i = j = n - middle + 1;
          }
        }
      }

      if (!flag) {
        top = middle - 1;
      }
    }
    cout << top << endl;
  }
}
Problem p00092 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)

#define PB push_back
#define INF INT_MAX / 3
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset(a, 0, sizeof(a))

typedef long long int ll;

using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    vector<vector<char>> map(n, vector<char>(n, '.'));
    REP(i, n) {
      REP(j, n) { cin >> map[i][j]; }
    }
    if (n == 0)
      break;
    bool flg = true;
    int high, low, middle;
    high = n + 1;
    low = 0;
    middle = (high + low) / 2;

    while (high - low > 1) {
      REP(j, n - middle + 1) {
        REP(k, n - middle + 1) {
          flg = true;
          REP(l, middle) {
            REP(m, middle) {
              if (map[j + l][k + m] == '*') {
                flg = false;
                k = k + m;
                if (k >= n - middle + 1)
                  break;
                break;
              }
            }
            if (!flg)
              break;
          }
          if (flg) {
            break;
          }
        }
        if (flg)
          break;
      }
      if (flg) {
        low = middle;
      } else {
        high = middle;
      }
      middle = (high + low) / 2;
    }
    cout << middle << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)

#define PB push_back
#define INF INT_MAX / 3
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset(a, 0, sizeof(a))

typedef long long int ll;

using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    vector<vector<char>> map(n, vector<char>(n, '.'));
    REP(i, n) {
      REP(j, n) { cin >> map[i][j]; }
    }
    if (n == 0)
      break;
    bool flg = true;
    int high, low, middle;
    high = n + 1;
    low = 0;
    middle = (high + low) / 2;

    while (high - low > 1) {
      REP(j, n - middle + 1) {
        REP(k, n - middle + 1) {
          flg = true;
          REP(l, middle) {
            REP(m, middle) {
              if (map[j + l][k + m] == '*') {
                flg = false;
                break;
              }
            }
            if (!flg)
              break;
          }
          if (flg) {
            break;
          }
        }
        if (flg)
          break;
      }
      if (flg) {
        low = middle;
      } else {
        high = middle;
      }
      middle = (high + low) / 2;
    }
    cout << middle << endl;
  }
  return 0;
}