Submission #505420

# Submission time Handle Problem Language Result Execution time Memory
505420 2022-01-11T04:59:59 Z pragmatist Bomb (IZhO17_bomb) C++17
23 / 100
1000 ms 18632 KB
#include <bits/stdc++.h>                            
 
#define pb push_back
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define x first
#define y second
#define int long long
#define nl "\n"
 
using namespace std;

typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair <ll, ll> pii;

const int N = (int)1e6 + 7;
const int M = (int)5e6 + 7;
const ll MOD = (ll)1e9 + 7;                    
const int inf = (int)1e9 + 7;
const ll INF = (ll)3e18 + 7;

pii dir[] = {{-1, -1}, {1, 1}, {-1, 1}, {1, -1}};

int n, m;
char c[2501][2501];
bool used[2501][2501];

void solve() {           
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			cin >> c[i][j];
		}
	}
	int ans = 0	;
	for(int e = 1; e <= n; ++e) {
		for(int f = 1; f <= n; ++f) {
			bool ok = 1;
			for(int i = 1; i <= n; ++i) fill(used[i] + 1, used[i] + 1 + m, 0);
			for(int i = 1; i <= n; ++i) {
				for(int j = 1; j <= n; ++j) {
			        if(i + e - 1 > n || j + f - 1 > m) continue;
					if(c[i][j] == '1') {
						bool cur = 1;
						for(int ii = i; ii <= i + e - 1 && cur; ++ii) {
							for(int jj = j; jj <= j + f - 1 && cur; ++jj) {
								cur &= (c[ii][jj] == '1');
							}
						}
						if(cur) {
							for(int ii = i; ii <= i + e - 1 && cur; ++ii) {
								for(int jj = j; jj <= j + f - 1 && cur; ++jj) {
									used[ii][jj] = 1;
								}
							}	
						}					
					}
				}
			}
			for(int i = 1; i <= n && ok; ++i) {
				for(int j = 1; j <= n && ok; ++j) {
					if(c[i][j] == '1') ok &= (used[i][j] == 1);
				}
			}
			if(ok) {
				ans = max(ans, e * f);
				//cout << e << ' ' << f << nl;
			}
		}
	}
	cout << ans << nl;
}
                
signed main() {                   
	ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
   	int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; ++i) {
        //cout << "Case " << i << ": ";
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Correct 1 ms 332 KB Output is correct
3 Execution timed out 1083 ms 12492 KB Time limit exceeded
4 Execution timed out 1022 ms 12460 KB Time limit exceeded
5 Incorrect 1 ms 344 KB Output isn't correct
6 Incorrect 0 ms 312 KB Output isn't correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 41 ms 640 KB Output is correct
18 Correct 30 ms 660 KB Output is correct
19 Correct 163 ms 776 KB Output is correct
20 Correct 178 ms 784 KB Output is correct
21 Correct 12 ms 592 KB Output is correct
22 Correct 47 ms 692 KB Output is correct
23 Correct 630 ms 808 KB Output is correct
24 Correct 127 ms 716 KB Output is correct
25 Correct 988 ms 812 KB Output is correct
26 Execution timed out 1073 ms 716 KB Time limit exceeded
27 Execution timed out 1018 ms 1728 KB Time limit exceeded
28 Execution timed out 1022 ms 1748 KB Time limit exceeded
29 Execution timed out 1025 ms 2372 KB Time limit exceeded
30 Execution timed out 1077 ms 2508 KB Time limit exceeded
31 Execution timed out 1057 ms 1996 KB Time limit exceeded
32 Execution timed out 1069 ms 2408 KB Time limit exceeded
33 Execution timed out 1092 ms 2636 KB Time limit exceeded
34 Execution timed out 1081 ms 2124 KB Time limit exceeded
35 Execution timed out 1088 ms 2636 KB Time limit exceeded
36 Execution timed out 1036 ms 2640 KB Time limit exceeded
37 Correct 1 ms 332 KB Output is correct
38 Execution timed out 1065 ms 18592 KB Time limit exceeded
39 Correct 2 ms 316 KB Output is correct
40 Execution timed out 1077 ms 5272 KB Time limit exceeded
41 Correct 2 ms 332 KB Output is correct
42 Execution timed out 1077 ms 708 KB Time limit exceeded
43 Execution timed out 1040 ms 18588 KB Time limit exceeded
44 Execution timed out 1008 ms 2628 KB Time limit exceeded
45 Execution timed out 1096 ms 18572 KB Time limit exceeded
46 Execution timed out 1080 ms 18632 KB Time limit exceeded
47 Execution timed out 1070 ms 18588 KB Time limit exceeded
48 Execution timed out 1094 ms 18616 KB Time limit exceeded
49 Execution timed out 1047 ms 18584 KB Time limit exceeded
50 Execution timed out 1030 ms 18580 KB Time limit exceeded
51 Execution timed out 1078 ms 18576 KB Time limit exceeded
52 Execution timed out 1047 ms 18584 KB Time limit exceeded
53 Execution timed out 1092 ms 18628 KB Time limit exceeded
54 Execution timed out 1006 ms 18596 KB Time limit exceeded
55 Execution timed out 1082 ms 18580 KB Time limit exceeded
56 Execution timed out 1054 ms 18620 KB Time limit exceeded
57 Execution timed out 1089 ms 18540 KB Time limit exceeded
58 Execution timed out 1045 ms 18628 KB Time limit exceeded
59 Execution timed out 1008 ms 18580 KB Time limit exceeded
60 Execution timed out 1098 ms 18572 KB Time limit exceeded
61 Execution timed out 1103 ms 18592 KB Time limit exceeded
62 Execution timed out 1014 ms 18532 KB Time limit exceeded
63 Execution timed out 1099 ms 18580 KB Time limit exceeded
64 Execution timed out 1047 ms 18628 KB Time limit exceeded
65 Execution timed out 1067 ms 18604 KB Time limit exceeded
66 Execution timed out 1030 ms 18588 KB Time limit exceeded
67 Execution timed out 1024 ms 18576 KB Time limit exceeded
68 Execution timed out 1055 ms 18596 KB Time limit exceeded
69 Execution timed out 1043 ms 18604 KB Time limit exceeded
70 Execution timed out 1069 ms 13904 KB Time limit exceeded
71 Execution timed out 1098 ms 18580 KB Time limit exceeded
72 Execution timed out 1082 ms 18588 KB Time limit exceeded
73 Execution timed out 1072 ms 18604 KB Time limit exceeded
74 Execution timed out 1096 ms 18604 KB Time limit exceeded
75 Execution timed out 1024 ms 18628 KB Time limit exceeded
76 Execution timed out 1002 ms 18580 KB Time limit exceeded
77 Execution timed out 1022 ms 18628 KB Time limit exceeded
78 Execution timed out 1014 ms 18600 KB Time limit exceeded
79 Execution timed out 1078 ms 18568 KB Time limit exceeded
80 Execution timed out 1077 ms 18604 KB Time limit exceeded
81 Execution timed out 1053 ms 18568 KB Time limit exceeded
82 Execution timed out 1102 ms 18588 KB Time limit exceeded
83 Execution timed out 1050 ms 18592 KB Time limit exceeded
84 Execution timed out 1097 ms 18588 KB Time limit exceeded
85 Execution timed out 1012 ms 18572 KB Time limit exceeded
86 Execution timed out 1059 ms 18540 KB Time limit exceeded
87 Execution timed out 1068 ms 18588 KB Time limit exceeded
88 Execution timed out 1086 ms 18572 KB Time limit exceeded
89 Execution timed out 1080 ms 18588 KB Time limit exceeded
90 Execution timed out 1069 ms 10096 KB Time limit exceeded
91 Execution timed out 1069 ms 12508 KB Time limit exceeded
92 Execution timed out 1070 ms 12504 KB Time limit exceeded
93 Execution timed out 1057 ms 12484 KB Time limit exceeded
94 Execution timed out 1052 ms 12504 KB Time limit exceeded
95 Execution timed out 1091 ms 12488 KB Time limit exceeded
96 Execution timed out 1066 ms 12464 KB Time limit exceeded
97 Execution timed out 1094 ms 12780 KB Time limit exceeded
98 Execution timed out 1087 ms 12916 KB Time limit exceeded
99 Execution timed out 1091 ms 12980 KB Time limit exceeded
100 Execution timed out 1074 ms 12984 KB Time limit exceeded