Submission #833321

# Submission time Handle Problem Language Result Execution time Memory
833321 2023-08-22T04:32:31 Z vjudge1 Bomb (IZhO17_bomb) C++17
8 / 100
84 ms 131072 KB
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define pll pair<long long, long long>
#define loop(i,n) for(int i=1;i<=n;i++)
#define loop0(i,n) for(int i=0;i<n;i++)
using namespace std;

//pbds template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

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

void solve(){
	ll n,m;
	cin >> n >> m;
	string a;
	ll arr[n+5][m+5] = {0};
	for(int i=1;i<=n;i++){
		cin >> a;
		for(int j=0;j<a.size();j++){
			if(a[j]=='0'){
				arr[i][j+1] = 0;
			}
			else{
				arr[i][j+1] = 1;
			}
		}
	}
	ll pref[n+5][m+5] = {0};
	ll pref2[n+5][m+5] = {0};
	for(int i=1;i<=n;i++){
		pref[i][0] = 0;
		for(int j=1;j<=m;j++){
			if(arr[i][j]==1){
				pref[i][j] = pref[i][j-1]+1;
			}
			else{
				pref[i][j] = 0;
			}
		}
	}
	for(int i=1;i<=m;i++){
		pref2[i][0] = 0;
		for(int j=1;j<=n;j++){
			if(arr[j][i]==1){
				pref2[i][j] = pref2[i][j-1]+1;
			}
			else{
				pref2[i][j] = 0;
			}
		}
	}
//	cout << endl;
	ll row = 1e18;
	ll col = 1e18;
	for(int i=1;i<=n;i++){
		ll act = 0;
		ll mn = 1e18;
		ll temp = 0;
		for(int j=1;j<=m;j++){
//			cout << pref[i][j] << ' ';
			if(act==0&&pref[i][j]!=0){
				act = 1;
				temp = max(temp,pref[i][j]);
			}
			else if(act==1){
				if(pref[i][j]==0){
					mn = min(mn,temp);
					act = 0;
					temp = 0;
				}
				else{
					temp = max(temp,pref[i][j]);
				}
			}
		}
		if(act==1){
			mn = min(mn,temp);
		}
		row = min(row,mn);
//		cout << endl;
	}
//	cout << endl;
	for(int i=1;i<=n;i++){
		ll act = 0;
		ll mn = 1e18;
		ll temp = 0;
		for(int j=1;j<=m;j++){
//			cout << pref2[i][j] << ' ';
			if(act==0&&pref2[i][j]!=0){
				act = 1;
				temp = max(temp,pref2[i][j]);
			}
			else if(act==1){
				if(pref2[i][j]==0){
					mn = min(mn,temp);
					act = 0;
					temp = 0;
				}
				else{
					temp = max(temp,pref2[i][j]);
				}
			}
		}
		if(act==1){
			mn = min(temp,mn);
		}
		col = min(col,mn);
//		cout << endl;
	}
	ll ans = row*col;
	cout << ans << endl;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc = 1;
//	cin >> tc;
	while(tc--){
	   solve();
	}
}

Compilation message

bomb.cpp: In function 'void solve()':
bomb.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for(int j=0;j<a.size();j++){
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Incorrect 0 ms 212 KB Output isn't correct
3 Incorrect 1 ms 596 KB Output isn't correct
4 Incorrect 1 ms 596 KB Output isn't correct
5 Runtime error 1 ms 1108 KB Execution killed with signal 11
6 Runtime error 1 ms 724 KB Execution killed with signal 11
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Incorrect 1 ms 212 KB Output isn't correct
11 Incorrect 0 ms 212 KB Output isn't correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Incorrect 0 ms 340 KB Output isn't correct
19 Incorrect 0 ms 468 KB Output isn't correct
20 Incorrect 1 ms 468 KB Output isn't correct
21 Incorrect 0 ms 340 KB Output isn't correct
22 Incorrect 0 ms 468 KB Output isn't correct
23 Incorrect 1 ms 468 KB Output isn't correct
24 Incorrect 1 ms 468 KB Output isn't correct
25 Incorrect 0 ms 468 KB Output isn't correct
26 Correct 0 ms 468 KB Output is correct
27 Correct 2 ms 2132 KB Output is correct
28 Incorrect 2 ms 2900 KB Output isn't correct
29 Incorrect 2 ms 3284 KB Output isn't correct
30 Incorrect 3 ms 4820 KB Output isn't correct
31 Incorrect 2 ms 3924 KB Output isn't correct
32 Incorrect 2 ms 4052 KB Output isn't correct
33 Incorrect 4 ms 5076 KB Output isn't correct
34 Incorrect 2 ms 2260 KB Output isn't correct
35 Incorrect 4 ms 5076 KB Output isn't correct
36 Correct 4 ms 5076 KB Output is correct
37 Incorrect 0 ms 212 KB Output isn't correct
38 Runtime error 67 ms 131072 KB Execution killed with signal 9
39 Incorrect 0 ms 212 KB Output isn't correct
40 Incorrect 15 ms 18648 KB Output isn't correct
41 Incorrect 1 ms 212 KB Output isn't correct
42 Incorrect 1 ms 468 KB Output isn't correct
43 Runtime error 60 ms 131072 KB Execution killed with signal 9
44 Incorrect 4 ms 5076 KB Output isn't correct
45 Runtime error 63 ms 131072 KB Execution killed with signal 9
46 Runtime error 63 ms 131072 KB Execution killed with signal 9
47 Runtime error 64 ms 131072 KB Execution killed with signal 9
48 Runtime error 66 ms 131072 KB Execution killed with signal 9
49 Runtime error 62 ms 131072 KB Execution killed with signal 9
50 Runtime error 62 ms 131072 KB Execution killed with signal 9
51 Runtime error 64 ms 131072 KB Execution killed with signal 9
52 Runtime error 65 ms 131072 KB Execution killed with signal 9
53 Runtime error 63 ms 131072 KB Execution killed with signal 9
54 Runtime error 64 ms 131072 KB Execution killed with signal 9
55 Runtime error 63 ms 131072 KB Execution killed with signal 9
56 Runtime error 61 ms 131072 KB Execution killed with signal 9
57 Runtime error 62 ms 131072 KB Execution killed with signal 9
58 Runtime error 65 ms 131072 KB Execution killed with signal 9
59 Runtime error 61 ms 131072 KB Execution killed with signal 9
60 Runtime error 66 ms 131072 KB Execution killed with signal 9
61 Runtime error 61 ms 131072 KB Execution killed with signal 9
62 Runtime error 60 ms 131072 KB Execution killed with signal 9
63 Runtime error 62 ms 131072 KB Execution killed with signal 9
64 Runtime error 64 ms 131072 KB Execution killed with signal 9
65 Runtime error 59 ms 131072 KB Execution killed with signal 9
66 Runtime error 63 ms 131072 KB Execution killed with signal 9
67 Runtime error 63 ms 131072 KB Execution killed with signal 9
68 Runtime error 61 ms 131072 KB Execution killed with signal 9
69 Runtime error 62 ms 131072 KB Execution killed with signal 9
70 Incorrect 84 ms 94604 KB Output isn't correct
71 Runtime error 62 ms 131072 KB Execution killed with signal 9
72 Runtime error 62 ms 131072 KB Execution killed with signal 9
73 Runtime error 78 ms 131072 KB Execution killed with signal 9
74 Runtime error 61 ms 131072 KB Execution killed with signal 9
75 Runtime error 63 ms 131072 KB Execution killed with signal 9
76 Runtime error 60 ms 131072 KB Execution killed with signal 9
77 Runtime error 62 ms 131072 KB Execution killed with signal 9
78 Runtime error 69 ms 131072 KB Execution killed with signal 9
79 Runtime error 61 ms 131072 KB Execution killed with signal 9
80 Runtime error 59 ms 131072 KB Execution killed with signal 9
81 Runtime error 63 ms 131072 KB Execution killed with signal 9
82 Runtime error 63 ms 131072 KB Execution killed with signal 9
83 Runtime error 61 ms 131072 KB Execution killed with signal 9
84 Runtime error 64 ms 131072 KB Execution killed with signal 9
85 Runtime error 66 ms 131072 KB Execution killed with signal 9
86 Runtime error 64 ms 131072 KB Execution killed with signal 9
87 Runtime error 63 ms 131072 KB Execution killed with signal 9
88 Runtime error 63 ms 131072 KB Execution killed with signal 9
89 Runtime error 64 ms 131072 KB Execution killed with signal 9
90 Incorrect 83 ms 94676 KB Output isn't correct
91 Runtime error 63 ms 131072 KB Execution killed with signal 9
92 Runtime error 66 ms 131072 KB Execution killed with signal 9
93 Runtime error 62 ms 131072 KB Execution killed with signal 9
94 Runtime error 65 ms 131072 KB Execution killed with signal 9
95 Runtime error 74 ms 131072 KB Execution killed with signal 9
96 Runtime error 61 ms 131072 KB Execution killed with signal 9
97 Runtime error 65 ms 131072 KB Execution killed with signal 9
98 Runtime error 65 ms 131072 KB Execution killed with signal 9
99 Runtime error 64 ms 131072 KB Execution killed with signal 9
100 Runtime error 63 ms 131072 KB Execution killed with signal 9