답안 #91543

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91543 2018-12-28T08:37:58 Z davitmarg Bomb (IZhO17_bomb) C++17
3 / 100
573 ms 99212 KB
/*
DEATH-MATCH
Davit-Marg
*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <ctype.h>
#include <stdlib.h>  
#include <fstream>  
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
using namespace std;

int n, m,w,h,l,r,mid;
int mp[2503][2503],pr[2503][2503];
char tmp;

int sum(int ys,int xs,int y,int x)
{
	xs--;
	ys--;
	return pr[y][x] - pr[y][xs] - pr[ys][x] + pr[ys][xs];
}

bool check(int x)
{
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (mp[i][j] && !mp[i - 1][j] && !mp[i][j - 1])
			{
				int s = sum(i, j, i + x - 1, j + w - 1);
				if (s != x * w)
					return 0;
			}

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (mp[i][j] && !mp[i + 1][j] && !mp[i][j + 1])
			{
				int s = sum(i-x+1,j-w+1,i, j);
				if (s != x * w)
					return 0;
			}


	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (mp[i][j] && !mp[i - 1][j] && !mp[i][j + 1])
			{
				int s = sum(i, j - w + 1, i + x - 1, j);
				if (s != x * w)
					return 0;
			}

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (mp[i][j] && !mp[i - 1][j] && !mp[i][j + 1])
			{
				int s = sum(i - x + 1, j, i, j + w - 1);
				if (s != x * w)
					return 0;
			}

	return 1;
}

int main()
{
	cin >> n >> m;
	w = m;
	h = n;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
		{
			cin >> tmp;
			mp[i][j] = tmp - '0';
			pr[i][j] = pr[i - 1][j] + pr[i][j - 1] - pr[i - 1][j - 1]+mp[i][j];
		}
	for (int i = 1; i <= n; i++)
	{
		int sum = 0;
		for (int j = 1; j <= m; j++)
		{
			sum += mp[i][j];
			if (mp[i][j] == 0)
			{
				if (sum)
					w = min(sum,w);
				sum = 0;
			}
		}
		if(sum)
			w = min(sum, w);
	}

	r = n;
	l = 1;
	while (l <= r)
	{
		mid = (l + r) / 2;
		if (check(mid))
		{
			h = mid;
			l = mid + 1;
		}
		else
			r = mid - 1;
	}

	cout << max(w * h,1) << endl;
	return 0;
}


/*



5 6
000000
111110
111111
111111
000000


7 8
01001110
01001110
01001100
00000000
01000000
01000000
01000000



7 8
01000000
00000000
00000000
00000000
00000000
00000000
00000000

7 8
11111111
11111111
11111111
11100111
11111111
11111111
11111111

7 8
00000000
00011000
00011000
00000000
00011111
00011111
00000000

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 596 KB Output isn't correct
3 Runtime error 79 ms 40896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 89 ms 40896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Correct 2 ms 40896 KB Output is correct
6 Correct 2 ms 40896 KB Output is correct
7 Incorrect 2 ms 40896 KB Output isn't correct
8 Incorrect 2 ms 40896 KB Output isn't correct
9 Incorrect 2 ms 40896 KB Output isn't correct
10 Incorrect 2 ms 40896 KB Output isn't correct
11 Incorrect 2 ms 40896 KB Output isn't correct
12 Incorrect 2 ms 40896 KB Output isn't correct
13 Incorrect 2 ms 40896 KB Output isn't correct
14 Incorrect 2 ms 40896 KB Output isn't correct
15 Incorrect 2 ms 40896 KB Output isn't correct
16 Incorrect 2 ms 40896 KB Output isn't correct
17 Incorrect 3 ms 40896 KB Output isn't correct
18 Incorrect 2 ms 40896 KB Output isn't correct
19 Incorrect 3 ms 40896 KB Output isn't correct
20 Incorrect 3 ms 40896 KB Output isn't correct
21 Incorrect 2 ms 40896 KB Output isn't correct
22 Incorrect 3 ms 40896 KB Output isn't correct
23 Incorrect 3 ms 40896 KB Output isn't correct
24 Incorrect 3 ms 40896 KB Output isn't correct
25 Incorrect 3 ms 40896 KB Output isn't correct
26 Runtime error 17 ms 40896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 18 ms 40896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Incorrect 11 ms 40896 KB Output isn't correct
29 Runtime error 26 ms 40896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Incorrect 19 ms 40896 KB Output isn't correct
31 Incorrect 15 ms 40896 KB Output isn't correct
32 Incorrect 16 ms 40896 KB Output isn't correct
33 Incorrect 20 ms 40896 KB Output isn't correct
34 Incorrect 9 ms 40896 KB Output isn't correct
35 Incorrect 19 ms 40896 KB Output isn't correct
36 Runtime error 34 ms 40896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Incorrect 2 ms 40896 KB Output isn't correct
38 Runtime error 440 ms 99004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Incorrect 2 ms 99004 KB Output isn't correct
40 Runtime error 84 ms 99004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Incorrect 2 ms 99004 KB Output isn't correct
42 Incorrect 3 ms 99004 KB Output isn't correct
43 Runtime error 463 ms 99004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
44 Incorrect 18 ms 99004 KB Output isn't correct
45 Incorrect 394 ms 99004 KB Output isn't correct
46 Runtime error 470 ms 99108 KB Execution killed with signal 11 (could be triggered by violating memory limits)
47 Incorrect 422 ms 99108 KB Output isn't correct
48 Incorrect 407 ms 99108 KB Output isn't correct
49 Runtime error 455 ms 99108 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Incorrect 389 ms 99108 KB Output isn't correct
51 Incorrect 392 ms 99108 KB Output isn't correct
52 Incorrect 380 ms 99108 KB Output isn't correct
53 Incorrect 382 ms 99108 KB Output isn't correct
54 Incorrect 383 ms 99108 KB Output isn't correct
55 Incorrect 425 ms 99108 KB Output isn't correct
56 Runtime error 435 ms 99108 KB Execution killed with signal 11 (could be triggered by violating memory limits)
57 Incorrect 440 ms 99108 KB Output isn't correct
58 Incorrect 410 ms 99108 KB Output isn't correct
59 Incorrect 425 ms 99108 KB Output isn't correct
60 Runtime error 449 ms 99108 KB Execution killed with signal 11 (could be triggered by violating memory limits)
61 Runtime error 447 ms 99108 KB Execution killed with signal 11 (could be triggered by violating memory limits)
62 Runtime error 438 ms 99108 KB Execution killed with signal 11 (could be triggered by violating memory limits)
63 Runtime error 428 ms 99108 KB Execution killed with signal 11 (could be triggered by violating memory limits)
64 Runtime error 434 ms 99108 KB Execution killed with signal 11 (could be triggered by violating memory limits)
65 Incorrect 374 ms 99108 KB Output isn't correct
66 Incorrect 377 ms 99108 KB Output isn't correct
67 Incorrect 391 ms 99108 KB Output isn't correct
68 Incorrect 384 ms 99108 KB Output isn't correct
69 Incorrect 419 ms 99108 KB Output isn't correct
70 Incorrect 318 ms 99108 KB Output isn't correct
71 Incorrect 495 ms 99108 KB Output isn't correct
72 Incorrect 550 ms 99108 KB Output isn't correct
73 Incorrect 542 ms 99108 KB Output isn't correct
74 Incorrect 540 ms 99108 KB Output isn't correct
75 Incorrect 547 ms 99108 KB Output isn't correct
76 Incorrect 516 ms 99108 KB Output isn't correct
77 Incorrect 524 ms 99108 KB Output isn't correct
78 Incorrect 573 ms 99108 KB Output isn't correct
79 Incorrect 483 ms 99108 KB Output isn't correct
80 Incorrect 453 ms 99108 KB Output isn't correct
81 Incorrect 486 ms 99108 KB Output isn't correct
82 Incorrect 528 ms 99108 KB Output isn't correct
83 Incorrect 530 ms 99108 KB Output isn't correct
84 Incorrect 437 ms 99108 KB Output isn't correct
85 Incorrect 504 ms 99108 KB Output isn't correct
86 Incorrect 439 ms 99108 KB Output isn't correct
87 Incorrect 501 ms 99108 KB Output isn't correct
88 Incorrect 530 ms 99108 KB Output isn't correct
89 Incorrect 507 ms 99108 KB Output isn't correct
90 Incorrect 344 ms 99108 KB Output isn't correct
91 Incorrect 505 ms 99108 KB Output isn't correct
92 Incorrect 526 ms 99108 KB Output isn't correct
93 Incorrect 444 ms 99212 KB Output isn't correct
94 Incorrect 572 ms 99212 KB Output isn't correct
95 Incorrect 555 ms 99212 KB Output isn't correct
96 Incorrect 541 ms 99212 KB Output isn't correct
97 Incorrect 428 ms 99212 KB Output isn't correct
98 Incorrect 563 ms 99212 KB Output isn't correct
99 Incorrect 510 ms 99212 KB Output isn't correct
100 Incorrect 453 ms 99212 KB Output isn't correct