제출 #170978

#제출 시각아이디문제언어결과실행 시간메모리
170978davitmargBomb (IZhO17_bomb)C++17
40 / 100
741 ms80248 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], pr[N][N], nxt[N][N], d[N], Y, X, ans; int get(int sy, int sx, int y, int x) { sy--; sx--; if (sy == -1 || sx == -1) return pr[y][x]; return pr[y][x] - pr[sy][x] - pr[y][sx] + pr[sy][sx]; } 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'); pr[i][j] = a[i][j] + pr[i - 1][j] + pr[i][j - 1] - pr[i - 1][j - 1]; } 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; else nxt[i][j] = 0; if (a[i][j - 1] == 0 && a[i][j]) X = min(X, nxt[i][j]); } for (int j = 1; j <= m; j++) { int y = 0; for (int i = 1; i <= n; i++) { if (a[i][j]) y++; else y = 0; if (a[i][j] && a[i + 1][j] == 0) Y = min(y, Y); } } for (int i = 1; i <= Y; i++) d[i] = X; for (int j = 1; j <= m; j++) { int y = 0, x = X; for (int i = 1; i <= n; i++) { if (a[i][j] == 0) { y = 0; x = X; } else { y++; x = min(x, nxt[i][j]); if (get(i - y + 1, j - 1, i, j - 1) != y) d[y] = min(x, d[y]); } //cout << i << " : " << j << " = " << y << " : " << x << endl; } } // for (int j = 1; j <= m; j++) // { // int y = 0, x = X; // for (int i = n; i >= 1; i--) // { // if (a[i][j] == 0) // { // y = 0; // x = X; // } // else // { // y++; // x = min(x, nxt[i][j]); // if (get(i, j - 1, i + y - 1, j - 1) != y) // d[y] = min(x, 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 111000 111000 111100 001111 000111 000111 6 6 000111 011111 011111 111000 111000 111000 */

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

bomb.cpp: In function 'int main()':
bomb.cpp:47: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...