Submission #666363

# Submission time Handle Problem Language Result Execution time Memory
666363 2022-11-28T10:01:25 Z Kaztaev_Alisher Bomb (IZhO17_bomb) C++17
30 / 100
1000 ms 45540 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 = 2e3+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[i1+x-1][j1+y-1] - dp[i1-1][j1+y-1] - dp[i1+x-1][j1-1] + dp[i1-1][j1-1];
					if(cnt == x*y) ok = 1;
					if(x == 3 && y == 1 && i == 1 && j == 3){
//						cout << cnt <<" | " << i1+x-1 <<" " << j1+y-1 <<" | " << i1-1 << ' ' << j1+x-1 <<" | " << i1+y-1<<" " << j1-1<<" | " << i1-1 <<" " << j1-1 <<"\n";
					}
				}	
			}
			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];
		}
	}
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		for(ll j = 1; j <= m; j++){
			if(check(i,j)){
				ans = max(ans , i*j);
			}
		}
	}
	cout << ans <<"\n";
}
signed main(){
	file("bomb");
	ios;
	solve();
	return 0;
}
/*
*/ 

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:17:48: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 | #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
      |                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
bomb.cpp:80:2: note: in expansion of macro 'file'
   80 |  file("bomb");
      |  ^~~~
bomb.cpp:17:77: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 | #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
      |                                                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bomb.cpp:80:2: note: in expansion of macro 'file'
   80 |  file("bomb");
      |  ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Runtime error 31 ms 24656 KB Execution killed with signal 11
4 Runtime error 30 ms 24712 KB Execution killed with signal 11
5 Correct 1 ms 340 KB Output is correct
6 Correct 4 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 0 ms 324 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 724 KB Output is correct
18 Correct 1 ms 724 KB Output is correct
19 Correct 7 ms 852 KB Output is correct
20 Correct 8 ms 932 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 68 ms 980 KB Output is correct
24 Correct 9 ms 852 KB Output is correct
25 Correct 169 ms 980 KB Output is correct
26 Correct 301 ms 980 KB Output is correct
27 Correct 14 ms 2388 KB Output is correct
28 Correct 7 ms 2516 KB Output is correct
29 Execution timed out 1085 ms 3156 KB Time limit exceeded
30 Execution timed out 1085 ms 3796 KB Time limit exceeded
31 Execution timed out 1073 ms 3028 KB Time limit exceeded
32 Execution timed out 1082 ms 3412 KB Time limit exceeded
33 Execution timed out 1071 ms 3928 KB Time limit exceeded
34 Correct 11 ms 2868 KB Output is correct
35 Execution timed out 1080 ms 3924 KB Time limit exceeded
36 Execution timed out 1082 ms 3976 KB Time limit exceeded
37 Correct 1 ms 340 KB Output is correct
38 Runtime error 98 ms 45388 KB Execution killed with signal 11
39 Correct 1 ms 340 KB Output is correct
40 Execution timed out 1084 ms 9300 KB Time limit exceeded
41 Correct 1 ms 340 KB Output is correct
42 Execution timed out 1083 ms 980 KB Time limit exceeded
43 Runtime error 98 ms 45540 KB Execution killed with signal 11
44 Execution timed out 1068 ms 3924 KB Time limit exceeded
45 Runtime error 86 ms 45308 KB Execution killed with signal 11
46 Runtime error 88 ms 45416 KB Execution killed with signal 11
47 Runtime error 88 ms 45388 KB Execution killed with signal 11
48 Runtime error 90 ms 45404 KB Execution killed with signal 11
49 Runtime error 86 ms 45408 KB Execution killed with signal 11
50 Runtime error 86 ms 45416 KB Execution killed with signal 11
51 Runtime error 91 ms 45348 KB Execution killed with signal 11
52 Runtime error 94 ms 45320 KB Execution killed with signal 11
53 Runtime error 86 ms 45332 KB Execution killed with signal 11
54 Runtime error 91 ms 45396 KB Execution killed with signal 11
55 Runtime error 97 ms 45440 KB Execution killed with signal 11
56 Runtime error 89 ms 45356 KB Execution killed with signal 11
57 Runtime error 91 ms 45356 KB Execution killed with signal 11
58 Runtime error 90 ms 45400 KB Execution killed with signal 11
59 Runtime error 88 ms 45384 KB Execution killed with signal 11
60 Runtime error 88 ms 45416 KB Execution killed with signal 11
61 Runtime error 92 ms 45408 KB Execution killed with signal 11
62 Runtime error 87 ms 45388 KB Execution killed with signal 11
63 Runtime error 89 ms 45416 KB Execution killed with signal 11
64 Runtime error 89 ms 45388 KB Execution killed with signal 11
65 Runtime error 89 ms 45460 KB Execution killed with signal 11
66 Runtime error 89 ms 45392 KB Execution killed with signal 11
67 Runtime error 84 ms 45300 KB Execution killed with signal 11
68 Runtime error 90 ms 45380 KB Execution killed with signal 11
69 Runtime error 97 ms 45372 KB Execution killed with signal 11
70 Execution timed out 1066 ms 23752 KB Time limit exceeded
71 Runtime error 89 ms 45388 KB Execution killed with signal 11
72 Runtime error 91 ms 45308 KB Execution killed with signal 11
73 Runtime error 87 ms 45412 KB Execution killed with signal 11
74 Runtime error 87 ms 45316 KB Execution killed with signal 11
75 Runtime error 92 ms 45432 KB Execution killed with signal 11
76 Runtime error 87 ms 45324 KB Execution killed with signal 11
77 Runtime error 89 ms 45356 KB Execution killed with signal 11
78 Runtime error 95 ms 45372 KB Execution killed with signal 11
79 Runtime error 92 ms 45316 KB Execution killed with signal 11
80 Runtime error 90 ms 45300 KB Execution killed with signal 11
81 Runtime error 88 ms 45320 KB Execution killed with signal 11
82 Runtime error 86 ms 45308 KB Execution killed with signal 11
83 Runtime error 95 ms 45408 KB Execution killed with signal 11
84 Runtime error 91 ms 45424 KB Execution killed with signal 11
85 Runtime error 87 ms 45320 KB Execution killed with signal 11
86 Runtime error 89 ms 45424 KB Execution killed with signal 11
87 Runtime error 88 ms 45404 KB Execution killed with signal 11
88 Runtime error 90 ms 45400 KB Execution killed with signal 11
89 Runtime error 92 ms 45372 KB Execution killed with signal 11
90 Execution timed out 1075 ms 23776 KB Time limit exceeded
91 Runtime error 91 ms 45368 KB Execution killed with signal 11
92 Runtime error 88 ms 45396 KB Execution killed with signal 11
93 Runtime error 91 ms 45428 KB Execution killed with signal 11
94 Runtime error 89 ms 45384 KB Execution killed with signal 11
95 Runtime error 88 ms 45412 KB Execution killed with signal 11
96 Runtime error 86 ms 45340 KB Execution killed with signal 11
97 Runtime error 92 ms 45344 KB Execution killed with signal 11
98 Runtime error 87 ms 45320 KB Execution killed with signal 11
99 Runtime error 87 ms 45432 KB Execution killed with signal 11
100 Runtime error 86 ms 45424 KB Execution killed with signal 11