Submission #333903

# Submission time Handle Problem Language Result Execution time Memory
333903 2020-12-08T02:46:25 Z talant117408 Bomb (IZhO17_bomb) C++17
14 / 100
241 ms 131076 KB
/*
    Code written by Talant I.D.
*/
  
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
  
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define OK cout << "OK" << endl;
  
inline bool isvowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}
  
inline bool isprime(int n){
    if(n < 2 || (n%2 == 0 && n != 2)) return false;
    for(int i = 3; i*i <= n; i++)
        if(n%i == 0) return false;
    return true;
}
 
class Union{
    private:
        vector <int> saizu, link;
    public:
        Union(int n){
            saizu.assign(n, 1); link.resize(n); 
            iota(all(link), 0);
        }
        int find(int n){
            if(link[n] == n) return n;
            return link[n] = find(link[n]);
        }
        int same(int a, int b){
            return find(a) == find(b);
        }
        void unite(int a, int b){
            if(same(a, b)) return;
             
            a = find(a); b = find(b);
            if(saizu[a] < saizu[b]) swap(a, b);
             
            saizu[a] += saizu[b];
            link[b] = a;
        }
        int getsize(int a){
            return saizu[find(a)];
        }
};
 
const int mod = 1e9+7;
 
ll mode(ll a){
    a %= mod;
    if(a < 0) a += mod;
    return a;
}
 
ll subt(ll a, ll b){
    return mode(mode(a)-mode(b));
}
 
ll add(ll a, ll b){
    return mode(mode(a)+mode(b));
}
 
ll mult(ll a, ll b){
    return mode(mode(a)*mode(b));
}
 
ll binpow(ll a, ll b){
    ll res = 1;
    while(b){
        if(b&1) res = mult(res, a);
        a = mult(a, a);
        b >>= 1;
    }
    return res;
}
/*
struct Node{
    ll val, l, r, sum;
    Node operator + (Node other){
        return {max(max(val, other.val), r+other.l), max(l, sum+other.l), max(other.r, other.sum+r), sum+other.sum}; 
    }
};

class Segment_tree{
    private:
        vector <Node> tree;
        //vector <int> lz;
    public:
        Segment_tree(int n){
            tree.resize(n*4);
            //lz.resize(n*4);
        }
        void build(int v, int l, int r){
            if(l == r){
                tree[v] = {max(0ll, vec[l]), max(0ll, vec[l]), max(0ll, vec[l]), vec[l]};
                return;
            }
            int mid = (l+r) >> 1;
            build(v*2, l, mid);
            build(v*2+1, mid+1, r);
            tree[v] = tree[v*2] + tree[v*2+1];
        }
        void push(int v, int l, int r){
            if(lz[v]){
                tree[v] += (r-l+1)*lz[v];
                if(l != r){
                    lz[v*2] += lz[v];
                    lz[v*2+1] += lz[v];
                }
                lz[v] = 0;
            }
        }
        int get(int v, int l, int r, int val){
            if(l == r){
                return l;
            }
            int mid = (l+r) >> 1;
            if(tree[v*2] >= val) return get(v*2, l, mid, val);
            else return get(v*2+1, mid+1, r, val);
        }
        void update(int v, int l, int r, int pos, ll val){
            if(l == r && l == pos){
                tree[v] = {max(0ll, val), max(0ll, val), max(0ll, val), val};
                return ;
            }
            int mid = (l+r) >> 1;  
            if(pos <= mid) update(v*2, l, mid, pos, val);
            else update(v*2+1, mid+1, r, pos, val);
            tree[v] = tree[v*2] + tree[v*2+1];
        }
        ll get_first(){
            return tree[1].val;
        }
};*/

int main(){
    do_not_disturb
    
    int n, m, i, j;
    cin >> n >> m;
    int grid[n+1][m+1];
    ll pref[2][n+2][m+2], suff[2][n+2][m+2];
    for(i = 1; i <= n; i++){
        for(j = 1; j <= m; j++){
            char ch;
            cin >> ch;
            grid[i][j] = int(ch-'0');
        }
    }
    
    for(i = 1; i <= n; i++){
        pref[0][i][0] = 0;
        suff[0][i][m+1] = m+1;
        for(j = 1; j <= m; j++){
            if(!grid[i][j]) pref[0][i][j] = j;
            else pref[0][i][j] = pref[0][i][j-1];
        }
        for(j = m; j; j--){
            if(!grid[i][j]) suff[0][i][j] = j;
            else suff[0][i][j] = suff[0][i][j+1];
        }
    }
    for(j = 1; j <= m; j++){
        pref[1][0][j] = 0;
        suff[1][n+1][j] = n+1;
        for(i = 1; i <= n; i++){
            if(!grid[i][j]) pref[1][i][j] = i;
            else pref[1][i][j] = pref[1][i-1][j];
        }
        for(i = n; i; i--){
            if(!grid[i][j]) suff[1][i][j] = i;
            else suff[1][i][j] = suff[1][i+1][j];
        }
    }
    
    ll mxx = 2e9, mxy = 2e9;
    
    for(i = 1; i <= n; i++){
        for(j = 1; j <= m; j++){
            if(grid[i][j]){
                mxx = min(mxx, suff[0][i][j]-pref[0][i][j]-1ll);
            }
        }
    }
    
    for(i = 1; i <= m; i++){
        for(j = 1; j <= n; j++){
            if(grid[j][i]){
                mxy = min(mxy, suff[1][j][i]-pref[1][j][i]-1ll);
            }
        }
    }
    /*
    for(i = 1; i <= n; i++){
        for(j = 1; j <= m; j++){
            cout << pref[0][i][j] << ' ';
        }
        cout << endl;
    }
    cout << endl;
    for(i = 1; i <= n; i++){
        for(j = 1; j <= m; j++){
            cout << suff[0][i][j] << ' ';
        }
        cout << endl;
    }
    cout << endl;
    for(i = 1; i <= n; i++){
        for(j = 1; j <= m; j++){
            cout << pref[1][i][j] << ' ';
        }
        cout << endl;
    }
    cout << endl;
    for(i = 1; i <= n; i++){
        for(j = 1; j <= m; j++){
            cout << suff[1][i][j] << ' ';
        }
        cout << endl;
    }
    cout << endl;
    
    cout << mxx << ' ' << mxy << endl;*/
    
    cout << (mxx == 2e9 ? 0 : mxx*mxy);
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 620 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Incorrect 1 ms 364 KB Output isn't correct
11 Incorrect 1 ms 364 KB Output isn't correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Incorrect 1 ms 364 KB Output isn't correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Incorrect 1 ms 492 KB Output isn't correct
19 Incorrect 1 ms 620 KB Output isn't correct
20 Incorrect 1 ms 620 KB Output isn't correct
21 Incorrect 1 ms 492 KB Output isn't correct
22 Incorrect 1 ms 620 KB Output isn't correct
23 Incorrect 1 ms 748 KB Output isn't correct
24 Incorrect 1 ms 492 KB Output isn't correct
25 Incorrect 1 ms 748 KB Output isn't correct
26 Correct 1 ms 748 KB Output is correct
27 Correct 4 ms 3180 KB Output is correct
28 Incorrect 5 ms 4352 KB Output isn't correct
29 Incorrect 7 ms 4844 KB Output isn't correct
30 Incorrect 10 ms 7160 KB Output isn't correct
31 Incorrect 8 ms 5868 KB Output isn't correct
32 Incorrect 8 ms 5996 KB Output isn't correct
33 Incorrect 12 ms 7660 KB Output isn't correct
34 Incorrect 5 ms 3308 KB Output isn't correct
35 Incorrect 11 ms 7660 KB Output isn't correct
36 Correct 16 ms 7660 KB Output is correct
37 Incorrect 1 ms 364 KB Output isn't correct
38 Runtime error 209 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Incorrect 1 ms 364 KB Output isn't correct
40 Incorrect 78 ms 28396 KB Output isn't correct
41 Incorrect 1 ms 364 KB Output isn't correct
42 Incorrect 1 ms 748 KB Output isn't correct
43 Runtime error 194 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
44 Incorrect 13 ms 7660 KB Output isn't correct
45 Runtime error 197 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
46 Runtime error 192 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
47 Runtime error 196 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
48 Runtime error 202 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
49 Runtime error 207 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
50 Runtime error 198 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
51 Runtime error 199 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
52 Runtime error 196 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
53 Runtime error 200 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
54 Runtime error 193 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
55 Runtime error 189 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
56 Runtime error 205 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
57 Runtime error 192 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
58 Runtime error 191 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
59 Runtime error 189 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
60 Runtime error 197 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
61 Runtime error 205 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
62 Runtime error 209 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
63 Runtime error 213 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
64 Runtime error 188 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
65 Runtime error 197 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
66 Runtime error 203 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
67 Runtime error 201 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
68 Runtime error 208 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
69 Runtime error 184 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
70 Runtime error 235 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
71 Runtime error 183 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
72 Runtime error 198 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
73 Runtime error 206 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
74 Runtime error 198 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
75 Runtime error 186 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
76 Runtime error 192 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
77 Runtime error 192 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
78 Runtime error 195 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
79 Runtime error 185 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
80 Runtime error 186 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
81 Runtime error 186 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
82 Runtime error 193 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
83 Runtime error 191 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
84 Runtime error 182 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
85 Runtime error 189 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
86 Runtime error 203 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
87 Runtime error 186 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
88 Runtime error 190 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
89 Runtime error 192 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
90 Runtime error 241 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
91 Runtime error 191 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
92 Runtime error 194 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
93 Runtime error 206 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
94 Runtime error 194 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
95 Runtime error 188 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
96 Runtime error 192 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
97 Runtime error 205 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
98 Runtime error 189 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
99 Runtime error 193 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
100 Runtime error 209 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)