Submission #666364

# Submission time Handle Problem Language Result Execution time Memory
666364 2022-11-28T10:04:09 Z Kaztaev_Alisher Bomb (IZhO17_bomb) C++17
30 / 100
1000 ms 42096 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[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];
		}
	}
	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:75:2: note: in expansion of macro 'file'
   75 |  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:75:2: note: in expansion of macro 'file'
   75 |  file("bomb");
      |  ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 29 ms 24700 KB Execution killed with signal 11
4 Runtime error 30 ms 24708 KB Execution killed with signal 11
5 Correct 1 ms 340 KB Output is correct
6 Correct 7 ms 336 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 456 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 716 KB Output is correct
18 Correct 1 ms 720 KB Output is correct
19 Correct 11 ms 940 KB Output is correct
20 Correct 13 ms 932 KB Output is correct
21 Correct 1 ms 584 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 128 ms 852 KB Output is correct
24 Correct 14 ms 852 KB Output is correct
25 Correct 287 ms 976 KB Output is correct
26 Correct 512 ms 976 KB Output is correct
27 Correct 25 ms 2388 KB Output is correct
28 Correct 16 ms 2612 KB Output is correct
29 Execution timed out 1079 ms 3156 KB Time limit exceeded
30 Execution timed out 1085 ms 3796 KB Time limit exceeded
31 Execution timed out 1083 ms 3028 KB Time limit exceeded
32 Execution timed out 1086 ms 3476 KB Time limit exceeded
33 Execution timed out 1086 ms 3924 KB Time limit exceeded
34 Correct 26 ms 2772 KB Output is correct
35 Execution timed out 1082 ms 3928 KB Time limit exceeded
36 Execution timed out 1076 ms 3924 KB Time limit exceeded
37 Correct 1 ms 340 KB Output is correct
38 Runtime error 90 ms 41964 KB Execution killed with signal 11
39 Correct 1 ms 340 KB Output is correct
40 Execution timed out 1078 ms 9300 KB Time limit exceeded
41 Correct 2 ms 340 KB Output is correct
42 Execution timed out 1081 ms 852 KB Time limit exceeded
43 Runtime error 97 ms 42000 KB Execution killed with signal 11
44 Execution timed out 1078 ms 3924 KB Time limit exceeded
45 Runtime error 91 ms 41988 KB Execution killed with signal 11
46 Runtime error 89 ms 42072 KB Execution killed with signal 11
47 Runtime error 97 ms 42020 KB Execution killed with signal 11
48 Runtime error 101 ms 42036 KB Execution killed with signal 11
49 Runtime error 95 ms 42024 KB Execution killed with signal 11
50 Runtime error 93 ms 42060 KB Execution killed with signal 11
51 Runtime error 91 ms 42060 KB Execution killed with signal 11
52 Runtime error 92 ms 42060 KB Execution killed with signal 11
53 Runtime error 97 ms 41920 KB Execution killed with signal 11
54 Runtime error 97 ms 42008 KB Execution killed with signal 11
55 Runtime error 91 ms 42048 KB Execution killed with signal 11
56 Runtime error 86 ms 42096 KB Execution killed with signal 11
57 Runtime error 86 ms 42096 KB Execution killed with signal 11
58 Runtime error 87 ms 42072 KB Execution killed with signal 11
59 Runtime error 98 ms 42060 KB Execution killed with signal 11
60 Runtime error 90 ms 42028 KB Execution killed with signal 11
61 Runtime error 85 ms 42080 KB Execution killed with signal 11
62 Runtime error 85 ms 42032 KB Execution killed with signal 11
63 Runtime error 104 ms 42056 KB Execution killed with signal 11
64 Runtime error 85 ms 42084 KB Execution killed with signal 11
65 Runtime error 85 ms 42060 KB Execution killed with signal 11
66 Runtime error 85 ms 41976 KB Execution killed with signal 11
67 Runtime error 91 ms 42016 KB Execution killed with signal 11
68 Runtime error 89 ms 42064 KB Execution killed with signal 11
69 Runtime error 99 ms 42060 KB Execution killed with signal 11
70 Execution timed out 1080 ms 21664 KB Time limit exceeded
71 Runtime error 86 ms 42000 KB Execution killed with signal 11
72 Runtime error 84 ms 42004 KB Execution killed with signal 11
73 Runtime error 86 ms 42060 KB Execution killed with signal 11
74 Runtime error 86 ms 42060 KB Execution killed with signal 11
75 Runtime error 86 ms 42024 KB Execution killed with signal 11
76 Runtime error 83 ms 42076 KB Execution killed with signal 11
77 Runtime error 86 ms 41808 KB Execution killed with signal 11
78 Runtime error 90 ms 41720 KB Execution killed with signal 11
79 Runtime error 94 ms 41836 KB Execution killed with signal 11
80 Runtime error 88 ms 41708 KB Execution killed with signal 11
81 Runtime error 85 ms 41568 KB Execution killed with signal 11
82 Runtime error 89 ms 41516 KB Execution killed with signal 11
83 Runtime error 85 ms 41420 KB Execution killed with signal 11
84 Runtime error 84 ms 41440 KB Execution killed with signal 11
85 Runtime error 85 ms 41428 KB Execution killed with signal 11
86 Runtime error 84 ms 41096 KB Execution killed with signal 11
87 Runtime error 86 ms 41000 KB Execution killed with signal 11
88 Runtime error 89 ms 41132 KB Execution killed with signal 11
89 Runtime error 87 ms 40908 KB Execution killed with signal 11
90 Execution timed out 1082 ms 20440 KB Time limit exceeded
91 Runtime error 87 ms 40780 KB Execution killed with signal 11
92 Runtime error 85 ms 40812 KB Execution killed with signal 11
93 Runtime error 91 ms 40704 KB Execution killed with signal 11
94 Runtime error 85 ms 40652 KB Execution killed with signal 11
95 Runtime error 83 ms 40668 KB Execution killed with signal 11
96 Runtime error 84 ms 40696 KB Execution killed with signal 11
97 Runtime error 87 ms 40408 KB Execution killed with signal 11
98 Runtime error 90 ms 40308 KB Execution killed with signal 11
99 Runtime error 83 ms 40260 KB Execution killed with signal 11
100 Runtime error 85 ms 40268 KB Execution killed with signal 11