답안 #833869

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
833869 2023-08-22T09:15:09 Z vjudge1 Bomb (IZhO17_bomb) C++14
37 / 100
247 ms 2728 KB
#include<bits/stdc++.h>
using namespace std;

const int MAX = 450 + 5;

int n,m,x[MAX][MAX],pf[MAX][MAX],atk[MAX][MAX];
char c;

int get(int x1,int y1,int x2,int y2){
	x1--, y1--;
	return pf[x2][y2] - pf[x2][y1] - pf[x1][y2] + pf[x1][y1];
}

bool bisa(int h,int w){
	memset(atk, 0, sizeof atk);
	for(int i = h; i<=n; i++){
		for(int j = w; j<=m; j++){
			if(get(i-h+1, j-w+1, i, j) == h*w){
				atk[i-h+1][j-w+1]++;
				atk[i-h+1][j+1]--;
				atk[i+1][j-w+1]--;
				atk[i+1][j+1]++;
			}
		}
	}
	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=m; j++){
			atk[i][j] = atk[i-1][j] + atk[i][j-1] - atk[i-1][j-1] + atk[i][j];
			if(atk[i][j]){
				if(!x[i][j])return false;
			}
			else {
				if(x[i][j])return false;
			}
		}
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	if(max(n,m)>450)return 1;
	
	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=m; j++){
			cin>>c;
			x[i][j] = (c=='1');
			pf[i][j] = pf[i-1][j] + pf[i][j-1] - pf[i-1][j-1] + x[i][j];
		}
	}
	
//	bisa(3, 1);
//	
//	for(int i = 1; i<=n; i++){
//		for(int j = 1; j<=m; j++){
//			cout<<atk[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	
	int ans = 0;
	int w = m;
	for(int h = 1; h<=n; h++){
		while(w && !bisa(h,w))w--;
		ans = max(ans, h*w);
	}
	
	cout<<ans<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
4 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
5 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
6 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 2 ms 1364 KB Output is correct
18 Correct 2 ms 1364 KB Output is correct
19 Correct 4 ms 1364 KB Output is correct
20 Correct 3 ms 1364 KB Output is correct
21 Correct 3 ms 1236 KB Output is correct
22 Correct 3 ms 1364 KB Output is correct
23 Correct 6 ms 1492 KB Output is correct
24 Correct 3 ms 1364 KB Output is correct
25 Correct 6 ms 1492 KB Output is correct
26 Correct 5 ms 1492 KB Output is correct
27 Correct 21 ms 2200 KB Output is correct
28 Correct 31 ms 2160 KB Output is correct
29 Correct 74 ms 2516 KB Output is correct
30 Correct 157 ms 2660 KB Output is correct
31 Correct 99 ms 2312 KB Output is correct
32 Correct 121 ms 2516 KB Output is correct
33 Correct 189 ms 2724 KB Output is correct
34 Correct 16 ms 2416 KB Output is correct
35 Correct 83 ms 2728 KB Output is correct
36 Correct 156 ms 2728 KB Output is correct
37 Correct 1 ms 1108 KB Output is correct
38 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
39 Correct 1 ms 1108 KB Output is correct
40 Runtime error 1 ms 232 KB Execution failed because the return code was nonzero
41 Correct 1 ms 1108 KB Output is correct
42 Correct 5 ms 1492 KB Output is correct
43 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
44 Correct 247 ms 2724 KB Output is correct
45 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
46 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
47 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
48 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
49 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
50 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
51 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
52 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
53 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
54 Runtime error 0 ms 240 KB Execution failed because the return code was nonzero
55 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
56 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
57 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
58 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
59 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
60 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
61 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
62 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
63 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
64 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
65 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
66 Runtime error 1 ms 256 KB Execution failed because the return code was nonzero
67 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
68 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
69 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
70 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
71 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
72 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
73 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
74 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
75 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
76 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
77 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
78 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
79 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
80 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
81 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
82 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
83 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
84 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
85 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
86 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
87 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
88 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
89 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
90 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
91 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
92 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
93 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
94 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
95 Runtime error 0 ms 232 KB Execution failed because the return code was nonzero
96 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
97 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
98 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
99 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
100 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero