Submission #833866

# Submission time Handle Problem Language Result Execution time Memory
833866 2023-08-22T09:14:42 Z vjudge1 Bomb (IZhO17_bomb) C++17
24 / 100
386 ms 60124 KB
#include <bits/stdc++.h>
using namespace std; 

int dpHorizontal[2505][2505] = {0}; 
int dpVertical[2505][2505] = {0}; 
char arr[2505][2505]; 

int main()
{
	int n, m; 
	cin >> n >> m; 
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> arr[i][j]; 
		}
	}
	int res = 0; 
	int sum = 0; 
		
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(arr[i - 1][j - 1] == '1')
			{
				dpHorizontal[i][j] = dpHorizontal[i][j - 1] + 1; 
			}
		}
	}
		
	for(int i = 1; i <= m; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(arr[j - 1][i - 1] == '1')
			{
				dpVertical[j][i] = dpVertical[j - 1][i] + 1; 
			}
		}
	}
		
		
	int minHorizontal = -1; 
    for(int i = 1; i <= n; i++)
    {
     	for(int j = 1; j <= m; j++)
     	{
     		if(dpHorizontal[i][j + 1] == 0 && dpHorizontal[i][j] > 0)
          	{
     		    	if(minHorizontal == -1)
     		    	{
     		    		minHorizontal = dpHorizontal[i][j]; 
			    	}
			    	else minHorizontal = min(minHorizontal, dpHorizontal[i][j]); 
		     	}
			}
		}
//		cout << minHorizontal << endl; 
		int minVertical = -1; 
		for(int i = 1; i <= m; i++)
     	{
     		for(int j = 1; j <= n; j++)
     		{
     			if(dpVertical[j + 1][i] == 0  && dpVertical[j][i] > 0)
     	      	{
     		    	if(minVertical == -1)
     		    	{
     		    		minVertical = dpVertical[j][i]; 
			    	}
			    	else minVertical= min(minVertical, dpVertical[j][i]); 
		     	}
			}
		}
		res = minHorizontal * minVertical; 
		

	cout << res << endl; 
	return 0; 
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:20:6: warning: unused variable 'sum' [-Wunused-variable]
   20 |  int sum = 0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 11 ms 26452 KB Output is correct
4 Correct 11 ms 26452 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 0 ms 340 KB Output isn't correct
9 Incorrect 1 ms 468 KB Output isn't correct
10 Incorrect 0 ms 340 KB Output isn't correct
11 Incorrect 1 ms 468 KB Output isn't correct
12 Incorrect 0 ms 468 KB Output isn't correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Incorrect 1 ms 468 KB Output isn't correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
18 Incorrect 1 ms 724 KB Output isn't correct
19 Incorrect 1 ms 980 KB Output isn't correct
20 Incorrect 1 ms 980 KB Output isn't correct
21 Incorrect 1 ms 468 KB Output isn't correct
22 Incorrect 1 ms 724 KB Output isn't correct
23 Incorrect 1 ms 980 KB Output isn't correct
24 Incorrect 1 ms 980 KB Output isn't correct
25 Incorrect 1 ms 1236 KB Output isn't correct
26 Correct 1 ms 1364 KB Output is correct
27 Correct 5 ms 3924 KB Output is correct
28 Incorrect 7 ms 1364 KB Output isn't correct
29 Incorrect 8 ms 5076 KB Output isn't correct
30 Incorrect 11 ms 4052 KB Output isn't correct
31 Incorrect 7 ms 3028 KB Output isn't correct
32 Incorrect 9 ms 4052 KB Output isn't correct
33 Incorrect 11 ms 5204 KB Output isn't correct
34 Incorrect 4 ms 1620 KB Output isn't correct
35 Incorrect 8 ms 1876 KB Output isn't correct
36 Correct 11 ms 6612 KB Output is correct
37 Incorrect 1 ms 468 KB Output isn't correct
38 Correct 351 ms 59420 KB Output is correct
39 Incorrect 1 ms 468 KB Output isn't correct
40 Incorrect 37 ms 15564 KB Output isn't correct
41 Incorrect 1 ms 592 KB Output isn't correct
42 Incorrect 1 ms 1364 KB Output isn't correct
43 Correct 329 ms 56012 KB Output is correct
44 Incorrect 10 ms 5972 KB Output isn't correct
45 Incorrect 386 ms 57420 KB Output isn't correct
46 Correct 323 ms 60028 KB Output is correct
47 Incorrect 334 ms 57512 KB Output isn't correct
48 Incorrect 314 ms 59852 KB Output isn't correct
49 Correct 359 ms 59824 KB Output is correct
50 Incorrect 325 ms 59840 KB Output isn't correct
51 Incorrect 314 ms 60124 KB Output isn't correct
52 Incorrect 321 ms 59876 KB Output isn't correct
53 Incorrect 321 ms 59384 KB Output isn't correct
54 Incorrect 299 ms 46668 KB Output isn't correct
55 Incorrect 304 ms 44656 KB Output isn't correct
56 Correct 350 ms 59596 KB Output is correct
57 Incorrect 288 ms 39756 KB Output isn't correct
58 Incorrect 288 ms 44640 KB Output isn't correct
59 Incorrect 296 ms 41380 KB Output isn't correct
60 Correct 313 ms 51252 KB Output is correct
61 Correct 340 ms 59312 KB Output is correct
62 Correct 340 ms 59532 KB Output is correct
63 Correct 363 ms 59340 KB Output is correct
64 Correct 294 ms 42188 KB Output is correct
65 Incorrect 313 ms 58700 KB Output isn't correct
66 Incorrect 355 ms 55948 KB Output isn't correct
67 Incorrect 312 ms 59932 KB Output isn't correct
68 Incorrect 349 ms 59812 KB Output isn't correct
69 Incorrect 295 ms 39396 KB Output isn't correct
70 Incorrect 159 ms 17996 KB Output isn't correct
71 Incorrect 295 ms 32884 KB Output isn't correct
72 Incorrect 301 ms 38052 KB Output isn't correct
73 Incorrect 295 ms 38504 KB Output isn't correct
74 Incorrect 289 ms 40076 KB Output isn't correct
75 Incorrect 303 ms 41656 KB Output isn't correct
76 Incorrect 317 ms 43180 KB Output isn't correct
77 Incorrect 321 ms 43436 KB Output isn't correct
78 Incorrect 328 ms 43536 KB Output isn't correct
79 Incorrect 267 ms 16036 KB Output isn't correct
80 Incorrect 282 ms 17236 KB Output isn't correct
81 Incorrect 278 ms 17380 KB Output isn't correct
82 Incorrect 321 ms 45736 KB Output isn't correct
83 Incorrect 300 ms 45884 KB Output isn't correct
84 Incorrect 266 ms 11112 KB Output isn't correct
85 Incorrect 310 ms 44748 KB Output isn't correct
86 Incorrect 368 ms 58440 KB Output isn't correct
87 Incorrect 305 ms 43664 KB Output isn't correct
88 Incorrect 296 ms 44676 KB Output isn't correct
89 Incorrect 300 ms 53420 KB Output isn't correct
90 Incorrect 191 ms 32164 KB Output isn't correct
91 Incorrect 306 ms 48592 KB Output isn't correct
92 Incorrect 315 ms 50276 KB Output isn't correct
93 Incorrect 336 ms 57332 KB Output isn't correct
94 Incorrect 326 ms 51812 KB Output isn't correct
95 Incorrect 302 ms 45768 KB Output isn't correct
96 Incorrect 305 ms 45640 KB Output isn't correct
97 Incorrect 345 ms 58236 KB Output isn't correct
98 Incorrect 308 ms 45452 KB Output isn't correct
99 Incorrect 322 ms 51636 KB Output isn't correct
100 Incorrect 356 ms 57080 KB Output isn't correct