Submission #1106814

# Submission time Handle Problem Language Result Execution time Memory
1106814 2024-10-31T05:36:30 Z stdfloat Bomb (IZhO17_bomb) C++17
4 / 100
1000 ms 8264 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	int n, m;
	cin >> n >> m;

	vector<string> a(n);
	for (auto &i : a)
		cin >> i;

	int mn1 = n, mn2 = m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i][j] == '0') continue;

			if (!i || a[i - 1][j] == '0') {
				int r = i;
				while (r + 1 < n && a[r + 1][j] == '1') r++;
				mn1 = min(mn1, r - i + 1);
			}

			if (!j || a[i][j - 1] == '0') {
				int r = i;
				while (r + 1 < m && a[i][r + 1] == '1') r++;
				mn2 = min(mn2, r - i + 1);
			}
		}
	}

	bool ok = true;
	vector<vector<bool>> vis(n, vector<bool>(m));
	for (int i = 0; i + mn1 <= n; i++) {
		for (int j = 0; j + mn2 <= m; j++) {
			if (a[i][j] == '0') continue;

			bool tr = true;
			for (int k = i; k < i + mn1 && tr; k++) {
				for (int l = j; l < j + mn2 && tr; l++)
					tr = (a[k][l] == '1');
			}

			ok = vis[i][j];
			if (!tr) continue;

			for (int k = i; k < i + mn1; k++) {
				for (int l = j; l < j + mn2; l++)
					vis[k][l] = true;
			}

			ok = true;
		}
	}

	for (int i = 0; i < n && ok; i++) {
		for (int j = 0; j < m && ok; j++)
			ok = (a[i][j] == '0' || vis[i][j]);
	}

	assert(ok);

	cout << mn1 * mn2;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 700 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Runtime error 1 ms 592 KB Execution killed with signal 6
6 Runtime error 1 ms 592 KB Execution killed with signal 6
7 Incorrect 1 ms 352 KB Output isn't correct
8 Runtime error 1 ms 604 KB Execution killed with signal 6
9 Runtime error 1 ms 604 KB Execution killed with signal 6
10 Incorrect 1 ms 348 KB Output isn't correct
11 Incorrect 1 ms 348 KB Output isn't correct
12 Correct 1 ms 348 KB Output is correct
13 Incorrect 1 ms 348 KB Output isn't correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Incorrect 1 ms 348 KB Output isn't correct
17 Incorrect 1 ms 348 KB Output isn't correct
18 Incorrect 1 ms 352 KB Output isn't correct
19 Incorrect 1 ms 348 KB Output isn't correct
20 Incorrect 1 ms 348 KB Output isn't correct
21 Incorrect 3 ms 336 KB Output isn't correct
22 Incorrect 1 ms 336 KB Output isn't correct
23 Incorrect 1 ms 336 KB Output isn't correct
24 Incorrect 1 ms 336 KB Output isn't correct
25 Runtime error 1 ms 592 KB Execution killed with signal 6
26 Incorrect 1 ms 348 KB Output isn't correct
27 Incorrect 1 ms 440 KB Output isn't correct
28 Incorrect 1 ms 592 KB Output isn't correct
29 Incorrect 17 ms 604 KB Output isn't correct
30 Incorrect 5 ms 604 KB Output isn't correct
31 Incorrect 3 ms 764 KB Output isn't correct
32 Incorrect 3 ms 604 KB Output isn't correct
33 Incorrect 8 ms 740 KB Output isn't correct
34 Incorrect 1 ms 508 KB Output isn't correct
35 Incorrect 1 ms 592 KB Output isn't correct
36 Incorrect 23 ms 592 KB Output isn't correct
37 Incorrect 1 ms 336 KB Output isn't correct
38 Incorrect 59 ms 8084 KB Output isn't correct
39 Incorrect 1 ms 504 KB Output isn't correct
40 Execution timed out 1070 ms 1448 KB Time limit exceeded
41 Incorrect 1 ms 336 KB Output isn't correct
42 Incorrect 1 ms 336 KB Output isn't correct
43 Execution timed out 1067 ms 8016 KB Time limit exceeded
44 Incorrect 29 ms 592 KB Output isn't correct
45 Execution timed out 1065 ms 8016 KB Time limit exceeded
46 Incorrect 92 ms 8016 KB Output isn't correct
47 Execution timed out 1055 ms 8016 KB Time limit exceeded
48 Incorrect 349 ms 7956 KB Output isn't correct
49 Incorrect 145 ms 8016 KB Output isn't correct
50 Incorrect 380 ms 8084 KB Output isn't correct
51 Incorrect 356 ms 8016 KB Output isn't correct
52 Incorrect 384 ms 8084 KB Output isn't correct
53 Incorrect 376 ms 8088 KB Output isn't correct
54 Incorrect 220 ms 8016 KB Output isn't correct
55 Incorrect 221 ms 8016 KB Output isn't correct
56 Incorrect 64 ms 8184 KB Output isn't correct
57 Incorrect 197 ms 7952 KB Output isn't correct
58 Incorrect 244 ms 8088 KB Output isn't correct
59 Incorrect 187 ms 8264 KB Output isn't correct
60 Incorrect 240 ms 7952 KB Output isn't correct
61 Incorrect 295 ms 8060 KB Output isn't correct
62 Execution timed out 1071 ms 8016 KB Time limit exceeded
63 Execution timed out 1076 ms 8016 KB Time limit exceeded
64 Incorrect 961 ms 8264 KB Output isn't correct
65 Incorrect 400 ms 8088 KB Output isn't correct
66 Incorrect 99 ms 8016 KB Output isn't correct
67 Incorrect 327 ms 8016 KB Output isn't correct
68 Incorrect 391 ms 8016 KB Output isn't correct
69 Incorrect 147 ms 8016 KB Output isn't correct
70 Incorrect 157 ms 5200 KB Output isn't correct
71 Incorrect 556 ms 8092 KB Output isn't correct
72 Incorrect 942 ms 8084 KB Output isn't correct
73 Incorrect 978 ms 8092 KB Output isn't correct
74 Incorrect 910 ms 8084 KB Output isn't correct
75 Execution timed out 1070 ms 7952 KB Time limit exceeded
76 Execution timed out 1002 ms 8088 KB Time limit exceeded
77 Execution timed out 1059 ms 7948 KB Time limit exceeded
78 Execution timed out 1006 ms 8084 KB Time limit exceeded
79 Incorrect 24 ms 8016 KB Output isn't correct
80 Incorrect 23 ms 7960 KB Output isn't correct
81 Incorrect 62 ms 8016 KB Output isn't correct
82 Execution timed out 1053 ms 8016 KB Time limit exceeded
83 Incorrect 945 ms 8016 KB Output isn't correct
84 Incorrect 20 ms 8016 KB Output isn't correct
85 Execution timed out 1090 ms 8016 KB Time limit exceeded
86 Incorrect 476 ms 8088 KB Output isn't correct
87 Incorrect 989 ms 8088 KB Output isn't correct
88 Execution timed out 1068 ms 8016 KB Time limit exceeded
89 Execution timed out 1066 ms 8016 KB Time limit exceeded
90 Incorrect 431 ms 5200 KB Output isn't correct
91 Execution timed out 1030 ms 8016 KB Time limit exceeded
92 Execution timed out 1083 ms 8016 KB Time limit exceeded
93 Incorrect 856 ms 8084 KB Output isn't correct
94 Execution timed out 1047 ms 8008 KB Time limit exceeded
95 Execution timed out 1056 ms 8084 KB Time limit exceeded
96 Execution timed out 1043 ms 8084 KB Time limit exceeded
97 Incorrect 505 ms 8264 KB Output isn't correct
98 Execution timed out 1062 ms 7952 KB Time limit exceeded
99 Execution timed out 1064 ms 8016 KB Time limit exceeded
100 Incorrect 969 ms 8016 KB Output isn't correct