답안 #666555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
666555 2022-11-29T02:43:03 Z Kaztaev_Alisher Bomb (IZhO17_bomb) C++17
16 / 100
1000 ms 37104 KB
//#pragma GCC optomize ("Ofast")
//#pragma GCC optomize ("unroll-loops")
//#pragma GCC target ("avx,avx2,fma")
 
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define sz size
#define cl clear
#define ins insert
#define ers erase
#define pii pair < int , int >
#define pll pair< long long  , long long >
#define all(x) x.begin() , x.end()
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define tostr(x) to_string(x)
#define tonum(s) atoi(s.c_str())
#define seon(x) setprecision(x)
#define bpop(x) __builtin_popcount(x)
#define deb(x) cerr << #x  << " = " << x << endl;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
const double PI = 3.14159265;
 
const ll N = 2500+5;
const ll mod = 1e9+7;
const ll inf = 1e9;
const ll INF = 1e18;
 
using namespace std;
 
char c[N][N];
int dp[N][N];
int n , m;
 
bool check(int x, int y){
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(c[i][j] == 0) continue;
			bool ok = 0;
			for(int i1 = max(1, i-x+1); i1 <= i; i1++){
				for(int j1 = max(1 , j-y+1); j1 <= j; j1++){
					int cnt = dp[min(i1+x-1 , n)][min(j1+y-1 , m)] - dp[i1-1][min(j1+y-1 , m)] - dp[min(i1+x-1 , n)][j1-1] + dp[i1-1][j1-1];
					if(cnt == x*y) ok = 1;
				}	
			}
			if(ok == 0) return 0;
		}
	}
	return 1;
}
void solve(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> c[i][j];
			c[i][j] -= '0';
			dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + c[i][j];
		}
	}
	int ans = 0;
	for(int l = 1, r = n*m; l <= r;){
		int md = (l+r) >> 1;
		bool ok = 0;
		for(int i = 1; i <= sqrt(md); i++){
			if(md % i == 0){
				int j = md/i;
				if(check(i,j)) ans = max(ans , i*j) , ok = 1;
				if(check(j,i)) ans = max(ans , i*j) , ok = 1;
			}
		}
		if(ok == 1) l = md+1;
		else r = md-1;
	}
	cout << ans <<"\n";
}
signed main(){
//	file("bomb");
	ios;
	solve();
	return 0;
}
/*
*/ 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 14 ms 16460 KB Output is correct
4 Correct 10 ms 16500 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Incorrect 1 ms 468 KB Output isn't correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Incorrect 0 ms 340 KB Output isn't correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Incorrect 1 ms 340 KB Output isn't correct
16 Incorrect 1 ms 340 KB Output isn't correct
17 Incorrect 1 ms 712 KB Output isn't correct
18 Correct 1 ms 724 KB Output is correct
19 Incorrect 1 ms 980 KB Output isn't correct
20 Incorrect 2 ms 852 KB Output isn't correct
21 Correct 1 ms 596 KB Output is correct
22 Incorrect 1 ms 852 KB Output isn't correct
23 Incorrect 4 ms 1036 KB Output isn't correct
24 Incorrect 1 ms 840 KB Output isn't correct
25 Incorrect 9 ms 980 KB Output isn't correct
26 Incorrect 8 ms 972 KB Output isn't correct
27 Correct 5 ms 2516 KB Output is correct
28 Incorrect 5 ms 2644 KB Output isn't correct
29 Execution timed out 1088 ms 3468 KB Time limit exceeded
30 Incorrect 629 ms 4028 KB Output isn't correct
31 Incorrect 56 ms 3212 KB Output isn't correct
32 Incorrect 151 ms 3788 KB Output isn't correct
33 Execution timed out 1077 ms 4180 KB Time limit exceeded
34 Correct 5 ms 3028 KB Output is correct
35 Incorrect 48 ms 4184 KB Output isn't correct
36 Execution timed out 1092 ms 4188 KB Time limit exceeded
37 Incorrect 1 ms 340 KB Output isn't correct
38 Execution timed out 1004 ms 36940 KB Time limit exceeded
39 Incorrect 1 ms 468 KB Output isn't correct
40 Execution timed out 1074 ms 9748 KB Time limit exceeded
41 Incorrect 1 ms 468 KB Output isn't correct
42 Incorrect 77 ms 1016 KB Output isn't correct
43 Execution timed out 1072 ms 37064 KB Time limit exceeded
44 Execution timed out 1084 ms 4180 KB Time limit exceeded
45 Execution timed out 1071 ms 37060 KB Time limit exceeded
46 Execution timed out 1064 ms 37104 KB Time limit exceeded
47 Execution timed out 1059 ms 36940 KB Time limit exceeded
48 Execution timed out 1078 ms 36996 KB Time limit exceeded
49 Execution timed out 1078 ms 36952 KB Time limit exceeded
50 Execution timed out 1082 ms 37000 KB Time limit exceeded
51 Execution timed out 1073 ms 37068 KB Time limit exceeded
52 Execution timed out 1056 ms 36932 KB Time limit exceeded
53 Execution timed out 1061 ms 36940 KB Time limit exceeded
54 Execution timed out 1068 ms 36944 KB Time limit exceeded
55 Execution timed out 1038 ms 37000 KB Time limit exceeded
56 Execution timed out 1063 ms 36960 KB Time limit exceeded
57 Execution timed out 1075 ms 37028 KB Time limit exceeded
58 Execution timed out 1078 ms 37044 KB Time limit exceeded
59 Execution timed out 1046 ms 37044 KB Time limit exceeded
60 Execution timed out 1037 ms 37080 KB Time limit exceeded
61 Execution timed out 1075 ms 37052 KB Time limit exceeded
62 Execution timed out 1068 ms 37036 KB Time limit exceeded
63 Execution timed out 1058 ms 37024 KB Time limit exceeded
64 Execution timed out 1083 ms 37040 KB Time limit exceeded
65 Execution timed out 1045 ms 37036 KB Time limit exceeded
66 Execution timed out 1081 ms 36952 KB Time limit exceeded
67 Execution timed out 1077 ms 36944 KB Time limit exceeded
68 Execution timed out 1076 ms 37008 KB Time limit exceeded
69 Execution timed out 1079 ms 36988 KB Time limit exceeded
70 Execution timed out 1072 ms 28780 KB Time limit exceeded
71 Execution timed out 1079 ms 37008 KB Time limit exceeded
72 Execution timed out 1079 ms 36968 KB Time limit exceeded
73 Execution timed out 1073 ms 37060 KB Time limit exceeded
74 Execution timed out 1081 ms 37056 KB Time limit exceeded
75 Execution timed out 1060 ms 36956 KB Time limit exceeded
76 Execution timed out 1039 ms 36948 KB Time limit exceeded
77 Execution timed out 1080 ms 36936 KB Time limit exceeded
78 Execution timed out 1064 ms 36992 KB Time limit exceeded
79 Incorrect 639 ms 37068 KB Output isn't correct
80 Incorrect 383 ms 36964 KB Output isn't correct
81 Execution timed out 1085 ms 37000 KB Time limit exceeded
82 Execution timed out 1061 ms 37068 KB Time limit exceeded
83 Execution timed out 1081 ms 36980 KB Time limit exceeded
84 Correct 289 ms 37072 KB Output is correct
85 Execution timed out 1070 ms 36968 KB Time limit exceeded
86 Execution timed out 1055 ms 37024 KB Time limit exceeded
87 Execution timed out 1066 ms 36944 KB Time limit exceeded
88 Execution timed out 1085 ms 36984 KB Time limit exceeded
89 Execution timed out 1084 ms 36952 KB Time limit exceeded
90 Execution timed out 1084 ms 28632 KB Time limit exceeded
91 Execution timed out 1065 ms 36944 KB Time limit exceeded
92 Execution timed out 1080 ms 36968 KB Time limit exceeded
93 Execution timed out 1037 ms 36956 KB Time limit exceeded
94 Execution timed out 1061 ms 37068 KB Time limit exceeded
95 Execution timed out 1077 ms 37024 KB Time limit exceeded
96 Execution timed out 1083 ms 37004 KB Time limit exceeded
97 Execution timed out 1073 ms 36952 KB Time limit exceeded
98 Execution timed out 1074 ms 37000 KB Time limit exceeded
99 Execution timed out 1063 ms 37000 KB Time limit exceeded
100 Execution timed out 1084 ms 36952 KB Time limit exceeded