Submission #170982

#TimeUsernameProblemLanguageResultExecution timeMemory
170982davitmargBomb (IZhO17_bomb)C++17
100 / 100
843 ms74116 KiB
/*DavitMarg*/ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <unordered_map> #include <set> #include <queue> #include <iomanip> #include <bitset> #include <stack> #include <cassert> #include <iterator> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back #define all(v) v.begin(), v.end() using namespace std; const int N = 2505; int n, m, a[N][N], nxt[N][N], lst[N][N], d[N], Y, X, ans; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { char x; scanf(" %c", &x); a[i][j] += (x - '0'); } X = m; Y = n; for (int i = 1; i <= n; i++) { for (int j = m; j >= 1; j--) { if (a[i][j]) { nxt[i][j] = nxt[i][j + 1] + 1; if (a[i][j - 1] == 0) X = min(nxt[i][j], X); } else nxt[i][j] = 0; } for (int j = 1; j <= m; j++) if (a[i][j]) lst[i][j] = lst[i][j - 1] + 1; else lst[i][j] = 0; } for (int i = 1; i <= Y; i++) d[i] = X; for (int j = 1; j <= m; j++) { int y = 0, l = X, r = X; for (int i = 1; i <= n; i++) { if (a[i][j] == 0) { y = 0; l = r = X; } else { y++; r = min(r, nxt[i][j]); l = min(l, lst[i][j]); d[y] = min(l + r - 1, d[y]); } //cout << i << " : " << j << " = " << y << " : " << x << endl; } y = 0; l = X; r = X; for (int i = n; i >= 1; i--) { if (a[i][j] == 0) { y = 0; l = r = X; } else { y++; if (a[i - 1][j] == 0) Y = min(y, Y); r = min(r, nxt[i][j]); l = min(l, lst[i][j]); d[y] = min(l + r - 1, d[y]); } //cout << i << " : " << j << " = " << y << " : " << x << endl; } } for (int i = 1; i <= Y; i++) { //d[i + 1] = min(d[i + 1], d[i]); //cout << i << " : " << d[i] << endl; ans = max(ans, i * d[i]); } cout << ans << endl; return 0; } /* 4 3 110 111 111 011 5 6 100000 111110 111110 111110 100000 6 5 00110 01110 11110 11011 11111 11111 9 9 000000000 000111000 000111000 011111110 011101110 011111110 000111000 000111000 000000000 9 9 000000000 000111000 000111000 011111110 011101110 011111110 000111000 000111000 000000000 6 6 000111 000111 001111 111100 111000 111000 6 6 000000 111000 111100 001111 000111 000111 6 6 000111 011111 011111 111000 111000 111000 */

Compilation message (stderr)

bomb.cpp: In function 'int main()':
bomb.cpp:38:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %c", &x);
             ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...