제출 #38400

#제출 시각아이디문제언어결과실행 시간메모리
38400TalantBomb (IZhO17_bomb)C++14
32 / 100
1000 ms131072 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define OK puts("OK"); #define pb push_back #define mk make_pair using namespace std; typedef long long ll; const int inf = (int)1e9 + 7; const int N = (int)1e6 + 10; int n,m; char a[2501][2501]; int t[2501][2501]; int c[2501][2501]; int mx,mn = inf,mn1 = inf; vector <pair<int,int> > v; bool check (int h,int w) { for (int i = h; i <= n; i ++) { for (int j = w; j <= m; j ++) { if (c[i][j] - c[i - h][j] - c[i][j - w] + c[i - h][j - w] == (h * w)) { for (int l = i - h + 1; l <= i; l ++) { for (int r = j - w + 1; r <= j; r ++) { t[l][r] = -1; } } } } } int f = 0; for (int i = 0; i < v.size(); i ++) { if (t[v[i].fr][v[i].sc] == 1) f = 1; t[v[i].fr][v[i].sc] = 1; } if (f) return false; return true; } int main () { cin >> n >> m; for (int i = 1; i <= n; i ++) scanf ("%s", a[i] + 1); for (int i = 1; i <= n; i ++) { int cnt = 0; for (int j = 1; j <= m; j ++) { t[i][j] = int(a[i][j] - '0'); c[i][j] = t[i][j]; if (t[i][j] == 1) v.pb(mk(i,j)); if (c[i][j] == 1) cnt ++; else { if (cnt > 0) mn = min(mn,cnt); cnt = 0; } } if (cnt > 0) mn = min(mn,cnt); } for (int i = 1; i <= m; i ++) { int cnt = 0; for (int j = 1; j <= n; j ++) { if (c[j][i] == 1) cnt ++; else { if (cnt > 0) mn1 = min(mn1,cnt); cnt = 0; } } if (cnt > 0) mn1 = min(mn1,cnt); } if (mn == inf) mn = 0; if (mn1 == inf) mn1 = 0; for (int i = 1; i <= n; i ++) for (int j = 2; j <= m; j ++) c[i][j] += c[i][j - 1]; for (int i = 2; i <= n; i ++) for (int j = 1; j <= m; j ++) c[i][j] += c[i - 1][j]; for (int i = 1; i <= mn1; i ++) { for (int j = 1; j <= mn; j ++) { if (mx >= i * j) continue; if (check(i,j)) mx = max(mx,i * j); } } cout << mx << endl; }

컴파일 시 표준 에러 (stderr) 메시지

bomb.cpp: In function 'bool check(int, int)':
bomb.cpp:37:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < v.size(); i ++) {
                           ^
bomb.cpp: In function 'int main()':
bomb.cpp:51:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 scanf ("%s", a[i] + 1);
                                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...