Submission #58872

# Submission time Handle Problem Language Result Execution time Memory
58872 2018-07-19T17:31:15 Z Benq Bomb (IZhO17_bomb) C++14
43 / 100
1000 ms 132096 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 2505;

char gr[MX][MX];
int n,m;
pi len[MX][MX];

vi temp() {
    int mx = m;
    vi z; F0R(i,mx+1) z.pb(MOD);
    /*F0R(i,n) {
        F0R(j,m) cout << gr[i][j];
        cout << "\n";
    }
    cout << "----\n";*/
    F0Rd(j,m) {
        int lst = 0;
        F0R(i,n) {
            if (gr[i][j] == '1') {
                
            } else {
                FOR(I,lst,i) len[I][j] = {lst,i-1};
                lst = i+1;
            }
        }
        FOR(I,lst,n) len[I][j] = {lst,n-1};
        F0R(i,n) {
            if (gr[i][j] == '1' && (j == 0 || gr[i][j-1] == '0')) {
                pi cur = {-MOD,MOD};
                FOR(x,j,m+1) {
                    if (x == m || gr[i][x] == '0') {
                        mx = min(mx,x-j);
                        break;
                    }
                    cur.f = max(cur.f,len[i][x].f);
                    cur.s = min(cur.s,len[i][x].s);
                    z[x-j+1] = min(z[x-j+1],cur.s-cur.f+1);
                }
                // cout << i << " " << j << "\n";
            }
        }
    }
    FOR(i,mx+1,sz(z)) z[i] = 0;
    return z;
}

vi solve() {
    vi x = temp();
    F0R(i,n) for (int j = 0; j < m-1-j; j++) swap(gr[i][j],gr[i][m-1-j]);
    vi X = temp();
    F0R(i,sz(x)) x[i] = min(x[i],X[i]);
    return x;
}

int main() {
    // freopen("bomb.in","r",stdin);
    // freopen("bomb.out","w",stdout);
    cin >> n >> m;
    F0R(i,n) F0R(j,m) cin >> gr[i][j];
    vi x = solve();
    swap(n,m);
    F0R(i,MX) FOR(j,i+1,MX) swap(gr[i][j],gr[j][i]);
    vi y = solve();
    
    int ans = 0;
    F0R(i,sz(x)) F0R(j,sz(y)) if (j <= x[i] && i <= y[j]) ans = max(ans,i*j);
    cout << ans;
}

/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
*/
# Verdict Execution time Memory Grader output
1 Correct 25 ms 6520 KB Output is correct
2 Correct 30 ms 6632 KB Output is correct
3 Correct 32 ms 16636 KB Output is correct
4 Correct 30 ms 16708 KB Output is correct
5 Correct 38 ms 16708 KB Output is correct
6 Correct 30 ms 16708 KB Output is correct
7 Correct 22 ms 16708 KB Output is correct
8 Correct 32 ms 16708 KB Output is correct
9 Correct 32 ms 16708 KB Output is correct
10 Correct 22 ms 16708 KB Output is correct
11 Correct 27 ms 16708 KB Output is correct
12 Correct 27 ms 16708 KB Output is correct
13 Correct 23 ms 16708 KB Output is correct
14 Correct 25 ms 16708 KB Output is correct
15 Correct 26 ms 16708 KB Output is correct
16 Correct 25 ms 16708 KB Output is correct
17 Correct 29 ms 16708 KB Output is correct
18 Correct 26 ms 16708 KB Output is correct
19 Correct 27 ms 16708 KB Output is correct
20 Correct 25 ms 16708 KB Output is correct
21 Correct 25 ms 16708 KB Output is correct
22 Correct 27 ms 16708 KB Output is correct
23 Correct 32 ms 16708 KB Output is correct
24 Correct 29 ms 16708 KB Output is correct
25 Correct 30 ms 16708 KB Output is correct
26 Correct 36 ms 16708 KB Output is correct
27 Correct 36 ms 16708 KB Output is correct
28 Correct 36 ms 16708 KB Output is correct
29 Correct 42 ms 16708 KB Output is correct
30 Correct 40 ms 16708 KB Output is correct
31 Correct 36 ms 16708 KB Output is correct
32 Correct 36 ms 16708 KB Output is correct
33 Correct 50 ms 16708 KB Output is correct
34 Correct 34 ms 16708 KB Output is correct
35 Correct 49 ms 16708 KB Output is correct
36 Correct 54 ms 16708 KB Output is correct
37 Correct 28 ms 16708 KB Output is correct
38 Execution timed out 1081 ms 63608 KB Time limit exceeded
39 Correct 32 ms 63608 KB Output is correct
40 Correct 149 ms 63608 KB Output is correct
41 Correct 24 ms 63608 KB Output is correct
42 Correct 27 ms 63608 KB Output is correct
43 Execution timed out 1073 ms 63608 KB Time limit exceeded
44 Correct 56 ms 63608 KB Output is correct
45 Execution timed out 1085 ms 76808 KB Time limit exceeded
46 Execution timed out 1088 ms 82988 KB Time limit exceeded
47 Execution timed out 1016 ms 89120 KB Time limit exceeded
48 Execution timed out 1093 ms 95268 KB Time limit exceeded
49 Execution timed out 1079 ms 101380 KB Time limit exceeded
50 Execution timed out 1087 ms 107364 KB Time limit exceeded
51 Execution timed out 1087 ms 113476 KB Time limit exceeded
52 Execution timed out 1081 ms 119648 KB Time limit exceeded
53 Execution timed out 1088 ms 125836 KB Time limit exceeded
54 Execution timed out 1018 ms 125836 KB Time limit exceeded
55 Correct 923 ms 126808 KB Output is correct
56 Execution timed out 1089 ms 132096 KB Time limit exceeded
57 Runtime error 999 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
58 Runtime error 952 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
59 Runtime error 785 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
60 Runtime error 981 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
61 Execution timed out 1085 ms 132096 KB Time limit exceeded
62 Execution timed out 1087 ms 132096 KB Time limit exceeded
63 Execution timed out 1097 ms 132096 KB Time limit exceeded
64 Runtime error 767 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
65 Runtime error 963 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
66 Execution timed out 1012 ms 132096 KB Time limit exceeded
67 Execution timed out 1094 ms 132096 KB Time limit exceeded
68 Execution timed out 1088 ms 132096 KB Time limit exceeded
69 Runtime error 879 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
70 Runtime error 422 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
71 Runtime error 834 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
72 Execution timed out 1034 ms 132096 KB Time limit exceeded
73 Runtime error 972 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
74 Execution timed out 1020 ms 132096 KB Time limit exceeded
75 Execution timed out 1088 ms 132096 KB Time limit exceeded
76 Runtime error 828 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
77 Runtime error 844 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
78 Runtime error 866 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
79 Runtime error 589 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
80 Runtime error 798 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
81 Runtime error 691 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
82 Runtime error 889 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
83 Execution timed out 1074 ms 132096 KB Time limit exceeded
84 Runtime error 717 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
85 Execution timed out 1031 ms 132096 KB Time limit exceeded
86 Execution timed out 1091 ms 132096 KB Time limit exceeded
87 Runtime error 819 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
88 Runtime error 883 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
89 Execution timed out 1082 ms 132096 KB Time limit exceeded
90 Runtime error 519 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
91 Execution timed out 1027 ms 132096 KB Time limit exceeded
92 Execution timed out 1082 ms 132096 KB Time limit exceeded
93 Execution timed out 1084 ms 132096 KB Time limit exceeded
94 Runtime error 984 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
95 Runtime error 877 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
96 Runtime error 830 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
97 Execution timed out 1093 ms 132096 KB Time limit exceeded
98 Execution timed out 1002 ms 132096 KB Time limit exceeded
99 Runtime error 979 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
100 Execution timed out 1092 ms 132096 KB Time limit exceeded