Submission #167193

# Submission time Handle Problem Language Result Execution time Memory
167193 2019-12-06T10:34:33 Z hentai_lover Bomb (IZhO17_bomb) C++14
26 / 100
427 ms 3448 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#define pb push_back
#define fr(i, l, r) for(ll i = l; i <= r; ++ i)
#define rf(i, l, r) for(ll i = l; i >= r; -- i)

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using _set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef int ll;
typedef pair<ll, ll> pll;

const ll oo = ll(1e9) + 10;

ll p[3000][300];

ll get(ll x1, ll y1, ll x2, ll y2){
    return p[x2][y2] - p[x2][y1 - 1] - p[x1 - 1][y2] + p[x1 - 1][y1 - 1];
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll n, m, ansx = 0, ansy = 0, ans = 0;
    cin >> n >> m;
    if(n * m > 10000)return 0;
    char a[n + 1][m + 1];
    fr(i, 1, n)fr(j, 1, m){
        cin >> a[i][j];
        p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1] + 1 - (a[i][j] - '0');
    }
    rf(r, n, 1){
        rf(c, m, 1){
            vector <pll> v;
            fr(i, 1, n - r + 1){
                fr(j, 1, m - c + 1){
                    //if(a[i][j] == '0')continue;
                    //cout << "i = " << i << " j = " << j << " get = " << get(i, j, i + r - 1, j + c - 1) << endl;
                    if(get(i, j, i + r - 1, j + c - 1) == 0)v.pb({i, j});
                }
            }
            reverse(v.begin(), v.end());
            //cout << "r = " << r << " c = " << c << endl;
            //cout << "v: " << endl;
            //for(auto i : v)cout << i.first << ' ' << i.second << endl;
            bool usd[n + 1][m + 1];
            fr(i, 1, n)fr(j, 1, m)usd[i][j] = 0;
            for(auto x : v){
                fr(i, 0, r - 1){
                    if(usd[x.first + i][x.second])break;
                    fr(j, 0, c - 1){
                        if(usd[x.first + i][x.second + j])break;
                        usd[x.first + i][x.second + j] = 1;
                    }
                }
            }

            bool ok = 1;
            fr(i, 1, n){
                fr(j, 1, m){
                    if(a[i][j] == '1' && usd[i][j] == 0)ok = 0;
                }
            }
            if(ok)ans = max(ans, r * c);
        }
    }
    //cout << ansx << ' ' << ansy << endl;
    cout << ans;
}


/*
3 3
011
111
111
*/

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:31:14: warning: unused variable 'ansx' [-Wunused-variable]
     ll n, m, ansx = 0, ansy = 0, ans = 0;
              ^~~~
bomb.cpp:31:24: warning: unused variable 'ansy' [-Wunused-variable]
     ll n, m, ansx = 0, ansy = 0, ans = 0;
                        ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 97 ms 3448 KB Output is correct
4 Correct 87 ms 3448 KB Output is correct
5 Correct 20 ms 504 KB Output is correct
6 Correct 10 ms 380 KB Output is correct
7 Correct 2 ms 372 KB Output is correct
8 Correct 3 ms 452 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Incorrect 29 ms 504 KB Output isn't correct
18 Correct 28 ms 504 KB Output is correct
19 Correct 74 ms 504 KB Output is correct
20 Correct 82 ms 504 KB Output is correct
21 Correct 29 ms 504 KB Output is correct
22 Incorrect 66 ms 504 KB Output isn't correct
23 Correct 138 ms 504 KB Output is correct
24 Correct 52 ms 504 KB Output is correct
25 Correct 152 ms 664 KB Output is correct
26 Correct 427 ms 912 KB Output is correct
27 Incorrect 2 ms 376 KB Output isn't correct
28 Incorrect 2 ms 376 KB Output isn't correct
29 Incorrect 2 ms 376 KB Output isn't correct
30 Incorrect 2 ms 376 KB Output isn't correct
31 Incorrect 2 ms 396 KB Output isn't correct
32 Incorrect 2 ms 436 KB Output isn't correct
33 Incorrect 2 ms 436 KB Output isn't correct
34 Incorrect 2 ms 376 KB Output isn't correct
35 Incorrect 2 ms 376 KB Output isn't correct
36 Incorrect 2 ms 376 KB Output isn't correct
37 Correct 3 ms 376 KB Output is correct
38 Incorrect 2 ms 376 KB Output isn't correct
39 Correct 3 ms 376 KB Output is correct
40 Incorrect 2 ms 376 KB Output isn't correct
41 Incorrect 15 ms 376 KB Output isn't correct
42 Incorrect 252 ms 788 KB Output isn't correct
43 Incorrect 2 ms 376 KB Output isn't correct
44 Incorrect 2 ms 376 KB Output isn't correct
45 Incorrect 2 ms 376 KB Output isn't correct
46 Incorrect 2 ms 376 KB Output isn't correct
47 Incorrect 2 ms 376 KB Output isn't correct
48 Incorrect 2 ms 376 KB Output isn't correct
49 Incorrect 2 ms 376 KB Output isn't correct
50 Incorrect 2 ms 376 KB Output isn't correct
51 Incorrect 2 ms 376 KB Output isn't correct
52 Incorrect 2 ms 376 KB Output isn't correct
53 Incorrect 2 ms 380 KB Output isn't correct
54 Incorrect 2 ms 376 KB Output isn't correct
55 Incorrect 2 ms 376 KB Output isn't correct
56 Incorrect 2 ms 376 KB Output isn't correct
57 Incorrect 2 ms 376 KB Output isn't correct
58 Incorrect 2 ms 376 KB Output isn't correct
59 Incorrect 2 ms 376 KB Output isn't correct
60 Incorrect 2 ms 376 KB Output isn't correct
61 Incorrect 2 ms 376 KB Output isn't correct
62 Incorrect 2 ms 376 KB Output isn't correct
63 Incorrect 2 ms 376 KB Output isn't correct
64 Incorrect 2 ms 376 KB Output isn't correct
65 Incorrect 2 ms 376 KB Output isn't correct
66 Incorrect 2 ms 376 KB Output isn't correct
67 Incorrect 2 ms 376 KB Output isn't correct
68 Incorrect 2 ms 376 KB Output isn't correct
69 Incorrect 2 ms 376 KB Output isn't correct
70 Incorrect 2 ms 380 KB Output isn't correct
71 Incorrect 2 ms 376 KB Output isn't correct
72 Incorrect 2 ms 376 KB Output isn't correct
73 Incorrect 2 ms 376 KB Output isn't correct
74 Incorrect 2 ms 376 KB Output isn't correct
75 Incorrect 2 ms 376 KB Output isn't correct
76 Incorrect 2 ms 376 KB Output isn't correct
77 Incorrect 2 ms 376 KB Output isn't correct
78 Incorrect 2 ms 376 KB Output isn't correct
79 Incorrect 2 ms 376 KB Output isn't correct
80 Incorrect 2 ms 376 KB Output isn't correct
81 Incorrect 2 ms 376 KB Output isn't correct
82 Incorrect 2 ms 376 KB Output isn't correct
83 Incorrect 2 ms 376 KB Output isn't correct
84 Incorrect 2 ms 376 KB Output isn't correct
85 Incorrect 2 ms 376 KB Output isn't correct
86 Incorrect 2 ms 380 KB Output isn't correct
87 Incorrect 2 ms 376 KB Output isn't correct
88 Incorrect 2 ms 376 KB Output isn't correct
89 Incorrect 2 ms 376 KB Output isn't correct
90 Incorrect 2 ms 376 KB Output isn't correct
91 Incorrect 2 ms 376 KB Output isn't correct
92 Incorrect 2 ms 376 KB Output isn't correct
93 Incorrect 2 ms 376 KB Output isn't correct
94 Incorrect 2 ms 376 KB Output isn't correct
95 Incorrect 2 ms 376 KB Output isn't correct
96 Incorrect 2 ms 376 KB Output isn't correct
97 Incorrect 2 ms 376 KB Output isn't correct
98 Incorrect 8 ms 376 KB Output isn't correct
99 Incorrect 2 ms 376 KB Output isn't correct
100 Incorrect 3 ms 376 KB Output isn't correct