Submission #833797

# Submission time Handle Problem Language Result Execution time Memory
833797 2023-08-22T08:40:53 Z vjudge1 Bomb (IZhO17_bomb) C++17
24 / 100
403 ms 58260 KB
#include <bits/stdc++.h>
using namespace std; 

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

int main()
{
	int n, m; 
	cin >> n >> m; 
	char arr[n + 5][m + 5]; 
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> arr[i][j]; 
		}
	}
	int res = 0; 
	int sum = 0; 
	if(n == 1 || m == 1)
	{
		if(n == 1)
		{
			for(int i = 0; i < m; i++)
			{
//				cout << res << " "; 
				if(arr[0][i] == '1')
				{
					sum++; 
				}
				else
				{
					if(res == 0)res = sum; 
					else if(res > 0 && sum > 0)
					{
						res = min(res, sum); 
					}
					sum = 0; 
				}
			}
			if(res == 0)res = sum; 
			else if(res > 0 && sum > 0) res = min(res, sum); 
	
		}
		else if(m == 1)
		{
			for(int i = 0; i < n; i++)
			{
//				cout << sum << " "; 
				if(arr[i][0] == '1')
				{
					sum++; 
				}
				else
				{
					if(res == 0)res = sum; 
					else if(res > 0 && sum > 0)
					{
						res = min(res, sum); 
					}
					sum = 0; 
				}
			}
			if(res == 0)res = sum; 
			else if(res > 0 && sum > 0)res = min(res, sum); 
		}
	}
	else
	{
		
		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; 
				}
			}
		}
		
//		for(int i = 0; i <= n; i++)
//		{
//			for(int j = 0; j <= m; j++)
//			{
//				cout << dpVertical[i][j] << " "; 
//			}
//			cout << endl; 
//		}
		
		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; 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Incorrect 1 ms 340 KB Output isn't correct
12 Incorrect 1 ms 340 KB Output isn't correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Incorrect 1 ms 340 KB Output isn't correct
16 Correct 1 ms 436 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Incorrect 1 ms 596 KB Output isn't correct
19 Incorrect 1 ms 724 KB Output isn't correct
20 Incorrect 2 ms 724 KB Output isn't correct
21 Incorrect 1 ms 440 KB Output isn't correct
22 Incorrect 2 ms 596 KB Output isn't correct
23 Incorrect 1 ms 724 KB Output isn't correct
24 Incorrect 1 ms 724 KB Output isn't correct
25 Incorrect 2 ms 1108 KB Output isn't correct
26 Correct 2 ms 1208 KB Output is correct
27 Correct 5 ms 3412 KB Output is correct
28 Incorrect 5 ms 832 KB Output isn't correct
29 Incorrect 7 ms 4436 KB Output isn't correct
30 Incorrect 9 ms 3360 KB Output isn't correct
31 Incorrect 7 ms 2508 KB Output isn't correct
32 Incorrect 9 ms 3284 KB Output isn't correct
33 Incorrect 10 ms 4444 KB Output isn't correct
34 Incorrect 4 ms 980 KB Output isn't correct
35 Incorrect 13 ms 1248 KB Output isn't correct
36 Correct 10 ms 5844 KB Output is correct
37 Incorrect 1 ms 468 KB Output isn't correct
38 Correct 403 ms 57432 KB Output is correct
39 Incorrect 1 ms 468 KB Output isn't correct
40 Incorrect 42 ms 14864 KB Output isn't correct
41 Incorrect 1 ms 468 KB Output isn't correct
42 Incorrect 2 ms 1108 KB Output isn't correct
43 Correct 343 ms 54056 KB Output is correct
44 Incorrect 10 ms 5204 KB Output isn't correct
45 Incorrect 355 ms 55464 KB Output isn't correct
46 Correct 363 ms 57916 KB Output is correct
47 Incorrect 368 ms 55468 KB Output isn't correct
48 Incorrect 337 ms 57984 KB Output isn't correct
49 Correct 399 ms 58004 KB Output is correct
50 Incorrect 347 ms 57896 KB Output isn't correct
51 Incorrect 356 ms 58260 KB Output isn't correct
52 Incorrect 337 ms 58100 KB Output isn't correct
53 Incorrect 340 ms 57468 KB Output isn't correct
54 Incorrect 323 ms 44692 KB Output isn't correct
55 Incorrect 313 ms 42792 KB Output isn't correct
56 Correct 368 ms 57880 KB Output is correct
57 Incorrect 305 ms 38020 KB Output isn't correct
58 Incorrect 301 ms 42824 KB Output isn't correct
59 Incorrect 310 ms 39624 KB Output isn't correct
60 Correct 344 ms 49584 KB Output is correct
61 Correct 371 ms 57696 KB Output is correct
62 Correct 369 ms 57652 KB Output is correct
63 Correct 381 ms 57756 KB Output is correct
64 Correct 289 ms 40508 KB Output is correct
65 Incorrect 323 ms 56960 KB Output isn't correct
66 Incorrect 338 ms 53976 KB Output isn't correct
67 Incorrect 348 ms 58160 KB Output isn't correct
68 Incorrect 346 ms 58156 KB Output isn't correct
69 Incorrect 304 ms 37768 KB Output isn't correct
70 Incorrect 161 ms 15896 KB Output isn't correct
71 Incorrect 289 ms 30984 KB Output isn't correct
72 Incorrect 296 ms 36476 KB Output isn't correct
73 Incorrect 304 ms 37028 KB Output isn't correct
74 Incorrect 312 ms 38424 KB Output isn't correct
75 Incorrect 294 ms 39992 KB Output isn't correct
76 Incorrect 299 ms 41548 KB Output isn't correct
77 Incorrect 306 ms 42280 KB Output isn't correct
78 Incorrect 308 ms 42620 KB Output isn't correct
79 Incorrect 252 ms 15172 KB Output isn't correct
80 Incorrect 249 ms 16756 KB Output isn't correct
81 Incorrect 258 ms 17092 KB Output isn't correct
82 Incorrect 296 ms 45332 KB Output isn't correct
83 Incorrect 303 ms 45600 KB Output isn't correct
84 Incorrect 248 ms 10908 KB Output isn't correct
85 Incorrect 295 ms 44512 KB Output isn't correct
86 Incorrect 338 ms 57932 KB Output isn't correct
87 Incorrect 279 ms 43428 KB Output isn't correct
88 Incorrect 306 ms 44456 KB Output isn't correct
89 Incorrect 310 ms 53108 KB Output isn't correct
90 Incorrect 174 ms 31012 KB Output isn't correct
91 Incorrect 299 ms 48344 KB Output isn't correct
92 Incorrect 311 ms 49936 KB Output isn't correct
93 Incorrect 353 ms 57156 KB Output isn't correct
94 Incorrect 310 ms 52008 KB Output isn't correct
95 Incorrect 292 ms 45780 KB Output isn't correct
96 Incorrect 294 ms 45308 KB Output isn't correct
97 Incorrect 345 ms 57804 KB Output isn't correct
98 Incorrect 292 ms 45132 KB Output isn't correct
99 Incorrect 318 ms 51388 KB Output isn't correct
100 Incorrect 353 ms 56560 KB Output isn't correct