# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
333900 |
2020-12-08T02:39:30 Z |
talant117408 |
Bomb (IZhO17_bomb) |
C++17 |
|
664 ms |
129268 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], 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];
}
}
int 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]-1);
}
}
}
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]-1);
}
}
}
/*
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*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 |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
364 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 |
364 KB |
Output is correct |
18 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
23 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
25 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
26 |
Correct |
1 ms |
492 KB |
Output is correct |
27 |
Correct |
4 ms |
2028 KB |
Output is correct |
28 |
Incorrect |
5 ms |
2668 KB |
Output isn't correct |
29 |
Incorrect |
6 ms |
2924 KB |
Output isn't correct |
30 |
Incorrect |
8 ms |
4204 KB |
Output isn't correct |
31 |
Incorrect |
6 ms |
3436 KB |
Output isn't correct |
32 |
Incorrect |
7 ms |
3564 KB |
Output isn't correct |
33 |
Incorrect |
11 ms |
4460 KB |
Output isn't correct |
34 |
Incorrect |
3 ms |
2028 KB |
Output isn't correct |
35 |
Incorrect |
8 ms |
4460 KB |
Output isn't correct |
36 |
Correct |
9 ms |
4460 KB |
Output is correct |
37 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
38 |
Correct |
664 ms |
129052 KB |
Output is correct |
39 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
40 |
Incorrect |
71 ms |
16236 KB |
Output isn't correct |
41 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
42 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
43 |
Correct |
605 ms |
128876 KB |
Output is correct |
44 |
Incorrect |
9 ms |
4480 KB |
Output isn't correct |
45 |
Incorrect |
600 ms |
129004 KB |
Output isn't correct |
46 |
Correct |
588 ms |
129064 KB |
Output is correct |
47 |
Incorrect |
580 ms |
128984 KB |
Output isn't correct |
48 |
Incorrect |
561 ms |
129004 KB |
Output isn't correct |
49 |
Correct |
621 ms |
128956 KB |
Output is correct |
50 |
Incorrect |
561 ms |
128876 KB |
Output isn't correct |
51 |
Incorrect |
543 ms |
128876 KB |
Output isn't correct |
52 |
Incorrect |
544 ms |
129004 KB |
Output isn't correct |
53 |
Incorrect |
526 ms |
129260 KB |
Output isn't correct |
54 |
Incorrect |
491 ms |
128876 KB |
Output isn't correct |
55 |
Incorrect |
493 ms |
129004 KB |
Output isn't correct |
56 |
Correct |
585 ms |
128876 KB |
Output is correct |
57 |
Incorrect |
485 ms |
128876 KB |
Output isn't correct |
58 |
Incorrect |
505 ms |
128876 KB |
Output isn't correct |
59 |
Incorrect |
494 ms |
129004 KB |
Output isn't correct |
60 |
Correct |
524 ms |
129004 KB |
Output is correct |
61 |
Correct |
590 ms |
129148 KB |
Output is correct |
62 |
Correct |
579 ms |
128876 KB |
Output is correct |
63 |
Correct |
584 ms |
128876 KB |
Output is correct |
64 |
Correct |
495 ms |
128876 KB |
Output is correct |
65 |
Incorrect |
517 ms |
129004 KB |
Output isn't correct |
66 |
Incorrect |
530 ms |
129132 KB |
Output isn't correct |
67 |
Incorrect |
539 ms |
129004 KB |
Output isn't correct |
68 |
Incorrect |
538 ms |
129004 KB |
Output isn't correct |
69 |
Incorrect |
486 ms |
128876 KB |
Output isn't correct |
70 |
Incorrect |
294 ms |
82668 KB |
Output isn't correct |
71 |
Incorrect |
476 ms |
129004 KB |
Output isn't correct |
72 |
Incorrect |
483 ms |
128876 KB |
Output isn't correct |
73 |
Incorrect |
496 ms |
128876 KB |
Output isn't correct |
74 |
Incorrect |
481 ms |
128876 KB |
Output isn't correct |
75 |
Incorrect |
498 ms |
129004 KB |
Output isn't correct |
76 |
Incorrect |
493 ms |
129004 KB |
Output isn't correct |
77 |
Incorrect |
494 ms |
128876 KB |
Output isn't correct |
78 |
Incorrect |
486 ms |
129004 KB |
Output isn't correct |
79 |
Incorrect |
448 ms |
129004 KB |
Output isn't correct |
80 |
Incorrect |
449 ms |
129004 KB |
Output isn't correct |
81 |
Incorrect |
454 ms |
129004 KB |
Output isn't correct |
82 |
Incorrect |
498 ms |
128876 KB |
Output isn't correct |
83 |
Incorrect |
496 ms |
128876 KB |
Output isn't correct |
84 |
Incorrect |
450 ms |
129004 KB |
Output isn't correct |
85 |
Incorrect |
495 ms |
128964 KB |
Output isn't correct |
86 |
Incorrect |
561 ms |
128876 KB |
Output isn't correct |
87 |
Incorrect |
485 ms |
128876 KB |
Output isn't correct |
88 |
Incorrect |
486 ms |
128876 KB |
Output isn't correct |
89 |
Incorrect |
505 ms |
128876 KB |
Output isn't correct |
90 |
Incorrect |
304 ms |
82668 KB |
Output isn't correct |
91 |
Incorrect |
510 ms |
129004 KB |
Output isn't correct |
92 |
Incorrect |
526 ms |
129004 KB |
Output isn't correct |
93 |
Incorrect |
558 ms |
128876 KB |
Output isn't correct |
94 |
Incorrect |
521 ms |
129004 KB |
Output isn't correct |
95 |
Incorrect |
482 ms |
129132 KB |
Output isn't correct |
96 |
Incorrect |
485 ms |
129004 KB |
Output isn't correct |
97 |
Incorrect |
564 ms |
128972 KB |
Output isn't correct |
98 |
Incorrect |
493 ms |
129004 KB |
Output isn't correct |
99 |
Incorrect |
508 ms |
129268 KB |
Output isn't correct |
100 |
Incorrect |
549 ms |
128876 KB |
Output isn't correct |