답안 #170417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170417 2019-12-25T06:37:32 Z davitmarg Bomb (IZhO17_bomb) C++17
4 / 100
564 ms 53112 KB
/*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], 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;
            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 <= n; 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 || (a[i][j - 1] == 1 && y == 0))
            {
                y = 0;
                x = X;
            }
            else
            {
                y++;
                x = min(x, nxt[i][j]);
                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 || (a[i][j + 1] == 1 && y == 0))
            {
                y = 0;
                x = X;
            }
            else
            {
                y++;
                x = min(x, nxt[i][j]);
                d[y] = min(x, d[y]);
            }
            //cout << i << " : " << j << " = " << y << " : " << x << endl;
        }
    }

    for (int i = 1; i <= Y; i++)
        ans = max(ans, i * d[i]);

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

/*

8 8
00000000
01111100
01111100
01111100
01101100
01111100
01111100
00000000
 
6 6
000111
000111
001111
111100
111000
111000
 
*/

Compilation message

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);
             ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 21 ms 20472 KB Output is correct
4 Correct 22 ms 20472 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Incorrect 2 ms 504 KB Output isn't correct
9 Incorrect 2 ms 504 KB Output isn't correct
10 Incorrect 2 ms 504 KB Output isn't correct
11 Incorrect 2 ms 504 KB Output isn't correct
12 Correct 2 ms 504 KB Output is correct
13 Incorrect 2 ms 504 KB Output isn't correct
14 Incorrect 2 ms 504 KB Output isn't correct
15 Incorrect 2 ms 504 KB Output isn't correct
16 Incorrect 2 ms 504 KB Output isn't correct
17 Incorrect 3 ms 888 KB Output isn't correct
18 Incorrect 3 ms 888 KB Output isn't correct
19 Incorrect 3 ms 1144 KB Output isn't correct
20 Incorrect 3 ms 1144 KB Output isn't correct
21 Incorrect 2 ms 760 KB Output isn't correct
22 Incorrect 3 ms 1020 KB Output isn't correct
23 Incorrect 3 ms 1144 KB Output isn't correct
24 Incorrect 3 ms 1016 KB Output isn't correct
25 Incorrect 3 ms 1276 KB Output isn't correct
26 Incorrect 3 ms 1276 KB Output isn't correct
27 Incorrect 10 ms 3464 KB Output isn't correct
28 Incorrect 10 ms 3704 KB Output isn't correct
29 Incorrect 13 ms 4604 KB Output isn't correct
30 Incorrect 16 ms 5496 KB Output isn't correct
31 Incorrect 13 ms 4344 KB Output isn't correct
32 Incorrect 17 ms 4984 KB Output isn't correct
33 Incorrect 18 ms 5752 KB Output isn't correct
34 Incorrect 9 ms 3832 KB Output isn't correct
35 Incorrect 18 ms 5752 KB Output isn't correct
36 Incorrect 33 ms 5752 KB Output isn't correct
37 Incorrect 2 ms 508 KB Output isn't correct
38 Incorrect 545 ms 52700 KB Output isn't correct
39 Incorrect 2 ms 504 KB Output isn't correct
40 Incorrect 62 ms 14080 KB Output isn't correct
41 Incorrect 2 ms 504 KB Output isn't correct
42 Incorrect 3 ms 1144 KB Output isn't correct
43 Incorrect 564 ms 52600 KB Output isn't correct
44 Incorrect 19 ms 5752 KB Output isn't correct
45 Incorrect 547 ms 52908 KB Output isn't correct
46 Incorrect 523 ms 52728 KB Output isn't correct
47 Incorrect 544 ms 52728 KB Output isn't correct
48 Incorrect 525 ms 52728 KB Output isn't correct
49 Incorrect 556 ms 52600 KB Output isn't correct
50 Incorrect 532 ms 52768 KB Output isn't correct
51 Incorrect 532 ms 52864 KB Output isn't correct
52 Incorrect 533 ms 52700 KB Output isn't correct
53 Incorrect 519 ms 52732 KB Output isn't correct
54 Incorrect 508 ms 52728 KB Output isn't correct
55 Incorrect 509 ms 52728 KB Output isn't correct
56 Incorrect 544 ms 53112 KB Output isn't correct
57 Incorrect 502 ms 52728 KB Output isn't correct
58 Incorrect 509 ms 52760 KB Output isn't correct
59 Incorrect 515 ms 52708 KB Output isn't correct
60 Incorrect 537 ms 52888 KB Output isn't correct
61 Incorrect 554 ms 52984 KB Output isn't correct
62 Incorrect 548 ms 52728 KB Output isn't correct
63 Incorrect 549 ms 53000 KB Output isn't correct
64 Incorrect 504 ms 52824 KB Output isn't correct
65 Incorrect 529 ms 52548 KB Output isn't correct
66 Incorrect 517 ms 52868 KB Output isn't correct
67 Incorrect 552 ms 52728 KB Output isn't correct
68 Incorrect 528 ms 52908 KB Output isn't correct
69 Incorrect 505 ms 52856 KB Output isn't correct
70 Incorrect 308 ms 43056 KB Output isn't correct
71 Incorrect 494 ms 52856 KB Output isn't correct
72 Incorrect 520 ms 52600 KB Output isn't correct
73 Incorrect 502 ms 52728 KB Output isn't correct
74 Incorrect 502 ms 52492 KB Output isn't correct
75 Incorrect 512 ms 52752 KB Output isn't correct
76 Incorrect 501 ms 52600 KB Output isn't correct
77 Incorrect 507 ms 52880 KB Output isn't correct
78 Incorrect 503 ms 52568 KB Output isn't correct
79 Incorrect 487 ms 52588 KB Output isn't correct
80 Incorrect 491 ms 52596 KB Output isn't correct
81 Incorrect 484 ms 52472 KB Output isn't correct
82 Incorrect 513 ms 52640 KB Output isn't correct
83 Incorrect 502 ms 52468 KB Output isn't correct
84 Incorrect 489 ms 52472 KB Output isn't correct
85 Incorrect 506 ms 52476 KB Output isn't correct
86 Incorrect 543 ms 52216 KB Output isn't correct
87 Incorrect 519 ms 52308 KB Output isn't correct
88 Incorrect 507 ms 52220 KB Output isn't correct
89 Incorrect 512 ms 52572 KB Output isn't correct
90 Incorrect 313 ms 42744 KB Output isn't correct
91 Incorrect 515 ms 52604 KB Output isn't correct
92 Incorrect 548 ms 52600 KB Output isn't correct
93 Incorrect 550 ms 52152 KB Output isn't correct
94 Incorrect 531 ms 52088 KB Output isn't correct
95 Incorrect 516 ms 52176 KB Output isn't correct
96 Incorrect 507 ms 52216 KB Output isn't correct
97 Incorrect 541 ms 52360 KB Output isn't correct
98 Incorrect 504 ms 52216 KB Output isn't correct
99 Incorrect 518 ms 51964 KB Output isn't correct
100 Incorrect 537 ms 51832 KB Output isn't correct