Submission #1102875

# Submission time Handle Problem Language Result Execution time Memory
1102875 2024-10-19T06:20:50 Z KasymK Bomb (IZhO17_bomb) C++17
99 / 100
338 ms 108104 KB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 2505;
int cep[N][N], sag[N][N], up[N][N], as[N][N], c[N];
char a[N][N];
 
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            scanf(" %c", &a[i][j]);
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j)
            cep[i][j] = (a[i][j]=='1'?cep[i][j-1]+1:0);
        for(int j = m; j >= 1; --j)
            sag[i][j] = (a[i][j]=='1'?sag[i][j+1]+1:0);
    }
    for(int j = 1; j <= m; ++j){
        for(int i = 1; i <= n; ++i)
            up[i][j] = (a[i][j]=='1'?up[i-1][j]+1:0);
        for(int i = n; i >= 1; --i)
            as[i][j] = (a[i][j]=='1'?as[i+1][j]+1:0);
    }
    int A = n, B = m;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            if(a[i][j] == '1')
                umin(A, up[i][j]+as[i][j]-1), umin(B, cep[i][j]+sag[i][j]-1);
    for(int i = 1; i <= A; ++i)
        c[i] = B;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j){
            if(a[i][j] != '1')
                continue;
            int now = B;
            if(as[i][j]==1)
                for(int k = i; k >= i-A+1; --k){
                    if(cep[i][j]==1)
                        umin(now, sag[k][j]), umin(c[i-k+1], now);
                    if(sag[i][j]==1)
                        umin(now, cep[k][j]), umin(c[i-k+1], now);
                }
            else if(up[i][j]==1)
                for(int k = i; k <= i+A-1; ++k){
                    if(cep[i][j]==1)
                        umin(now, sag[k][j]), umin(c[k-i+1], now);
                    if(sag[i][j]==1)
                        umin(now, cep[k][j]), umin(c[k-i+1], now);
                }
        }
    int answer = 1;
    for(int i = 1; i <= A; ++i)
        umax(answer, i*c[i]);
    printf("%d\n", answer);
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
bomb.cpp:24:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |             scanf(" %c", &a[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8528 KB Output is correct
2 Correct 1 ms 4688 KB Output is correct
3 Correct 25 ms 73296 KB Output is correct
4 Correct 26 ms 73296 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 2 ms 6736 KB Output is correct
9 Correct 2 ms 6736 KB Output is correct
10 Correct 1 ms 6480 KB Output is correct
11 Correct 1 ms 6736 KB Output is correct
12 Correct 1 ms 4860 KB Output is correct
13 Correct 2 ms 8528 KB Output is correct
14 Correct 1 ms 4700 KB Output is correct
15 Correct 1 ms 4688 KB Output is correct
16 Correct 1 ms 2640 KB Output is correct
17 Correct 2 ms 16976 KB Output is correct
18 Correct 3 ms 13136 KB Output is correct
19 Correct 3 ms 15184 KB Output is correct
20 Correct 2 ms 15184 KB Output is correct
21 Correct 3 ms 16976 KB Output is correct
22 Correct 3 ms 19024 KB Output is correct
23 Correct 3 ms 15352 KB Output is correct
24 Correct 3 ms 15184 KB Output is correct
25 Correct 3 ms 15184 KB Output is correct
26 Correct 2 ms 8016 KB Output is correct
27 Correct 8 ms 14192 KB Output is correct
28 Correct 7 ms 23376 KB Output is correct
29 Correct 9 ms 25948 KB Output is correct
30 Correct 11 ms 22728 KB Output is correct
31 Correct 9 ms 22608 KB Output is correct
32 Correct 9 ms 22608 KB Output is correct
33 Correct 11 ms 26908 KB Output is correct
34 Correct 7 ms 27324 KB Output is correct
35 Correct 10 ms 27508 KB Output is correct
36 Correct 13 ms 20304 KB Output is correct
37 Correct 1 ms 6736 KB Output is correct
38 Correct 290 ms 107336 KB Output is correct
39 Correct 1 ms 6736 KB Output is correct
40 Incorrect 42 ms 37484 KB Output isn't correct
41 Correct 1 ms 6736 KB Output is correct
42 Correct 3 ms 13648 KB Output is correct
43 Correct 289 ms 106516 KB Output is correct
44 Correct 12 ms 25680 KB Output is correct
45 Correct 302 ms 104540 KB Output is correct
46 Correct 294 ms 104520 KB Output is correct
47 Correct 290 ms 107848 KB Output is correct
48 Correct 307 ms 104560 KB Output is correct
49 Correct 301 ms 104556 KB Output is correct
50 Correct 338 ms 104552 KB Output is correct
51 Correct 312 ms 104556 KB Output is correct
52 Correct 332 ms 106316 KB Output is correct
53 Correct 316 ms 104552 KB Output is correct
54 Correct 294 ms 104440 KB Output is correct
55 Correct 320 ms 104520 KB Output is correct
56 Correct 323 ms 104568 KB Output is correct
57 Correct 327 ms 104556 KB Output is correct
58 Correct 306 ms 108104 KB Output is correct
59 Correct 309 ms 104520 KB Output is correct
60 Correct 305 ms 104520 KB Output is correct
61 Correct 304 ms 107116 KB Output is correct
62 Correct 318 ms 107848 KB Output is correct
63 Correct 326 ms 104548 KB Output is correct
64 Correct 317 ms 104520 KB Output is correct
65 Correct 323 ms 104676 KB Output is correct
66 Correct 320 ms 104552 KB Output is correct
67 Correct 310 ms 104552 KB Output is correct
68 Correct 293 ms 104520 KB Output is correct
69 Correct 286 ms 104432 KB Output is correct
70 Correct 185 ms 89196 KB Output is correct
71 Correct 271 ms 104556 KB Output is correct
72 Correct 274 ms 104528 KB Output is correct
73 Correct 282 ms 104564 KB Output is correct
74 Correct 280 ms 104520 KB Output is correct
75 Correct 274 ms 104520 KB Output is correct
76 Correct 314 ms 104520 KB Output is correct
77 Correct 301 ms 104520 KB Output is correct
78 Correct 309 ms 104556 KB Output is correct
79 Correct 287 ms 104520 KB Output is correct
80 Correct 286 ms 104556 KB Output is correct
81 Correct 327 ms 107772 KB Output is correct
82 Correct 298 ms 104520 KB Output is correct
83 Correct 316 ms 104520 KB Output is correct
84 Correct 286 ms 104552 KB Output is correct
85 Correct 314 ms 107848 KB Output is correct
86 Correct 312 ms 104788 KB Output is correct
87 Correct 297 ms 104520 KB Output is correct
88 Correct 323 ms 104428 KB Output is correct
89 Correct 304 ms 104520 KB Output is correct
90 Correct 202 ms 88392 KB Output is correct
91 Correct 320 ms 104524 KB Output is correct
92 Correct 312 ms 104520 KB Output is correct
93 Correct 318 ms 104520 KB Output is correct
94 Correct 305 ms 104552 KB Output is correct
95 Correct 316 ms 104552 KB Output is correct
96 Correct 279 ms 104520 KB Output is correct
97 Correct 276 ms 104520 KB Output is correct
98 Correct 280 ms 107852 KB Output is correct
99 Correct 280 ms 104776 KB Output is correct
100 Correct 264 ms 104536 KB Output is correct