Submission #710404

# Submission time Handle Problem Language Result Execution time Memory
710404 2023-03-15T08:19:55 Z pavement Bomb (IZhO17_bomb) C++17
15 / 100
170 ms 131076 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using db = double;
using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using iii = tuple<int, int, int>;
using iiii = tuple<int, int, int, int>;
template<class key, class value = null_type, class cmp = less<key> >
using ordered_set = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

int N, M, width = LLONG_MAX, height = LLONG_MAX, up[2505][2505], down[2505][2505], lft[2505][2505], rig[2505][2505];
char C[2505][2505];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			cin >> C[i][j];
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (C[i][j] == '1') {
				up[i][j] = (i > 1 && up[i - 1][j] ? up[i - 1][j] : i);
				lft[i][j] = (j > 1 && lft[i][j - 1] ? lft[i][j - 1] : j);
			}
		}
		for (int j = M; j >= 1; j--) {
			if (C[i][j] == '1') rig[i][j] = (j < M && rig[i][j + 1] ? rig[i][j + 1] : j);
		}
	}
	for (int i = N; i >= 1; i--) {
		for (int j = 1; j <= M; j++) {
			if (C[i][j] == '1') down[i][j] = (i < N && down[i + 1][j] ? down[i + 1][j] : i);
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (C[i][j] == '1') {
				width = min(width, rig[i][j] - lft[i][j] + 1);
				height = min(height, down[i][j] - up[i][j] + 1);
			}
		}
	}
	assert(width != LLONG_MAX && height != LLONG_MAX);
	cout << width * height << '\n';
}

Compilation message

bomb.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 18 ms 46696 KB Output is correct
4 Correct 17 ms 46676 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 1 ms 596 KB Output isn't correct
9 Incorrect 1 ms 596 KB Output isn't correct
10 Incorrect 1 ms 596 KB Output isn't correct
11 Incorrect 1 ms 592 KB Output isn't correct
12 Incorrect 1 ms 584 KB Output isn't correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Incorrect 1 ms 596 KB Output isn't correct
16 Correct 1 ms 724 KB Output is correct
17 Correct 1 ms 1620 KB Output is correct
18 Incorrect 1 ms 1108 KB Output isn't correct
19 Incorrect 1 ms 1492 KB Output isn't correct
20 Incorrect 1 ms 1492 KB Output isn't correct
21 Incorrect 1 ms 724 KB Output isn't correct
22 Incorrect 1 ms 1108 KB Output isn't correct
23 Incorrect 1 ms 1620 KB Output isn't correct
24 Incorrect 1 ms 1492 KB Output isn't correct
25 Incorrect 2 ms 2132 KB Output isn't correct
26 Correct 2 ms 2516 KB Output is correct
27 Correct 5 ms 8276 KB Output is correct
28 Incorrect 3 ms 1904 KB Output isn't correct
29 Incorrect 7 ms 10628 KB Output isn't correct
30 Incorrect 7 ms 7764 KB Output isn't correct
31 Incorrect 5 ms 5460 KB Output isn't correct
32 Incorrect 6 ms 7252 KB Output isn't correct
33 Incorrect 8 ms 10196 KB Output isn't correct
34 Incorrect 2 ms 2264 KB Output isn't correct
35 Incorrect 5 ms 2772 KB Output isn't correct
36 Correct 10 ms 15196 KB Output is correct
37 Incorrect 1 ms 724 KB Output isn't correct
38 Runtime error 156 ms 131072 KB Execution killed with signal 9
39 Incorrect 1 ms 724 KB Output isn't correct
40 Incorrect 35 ms 41360 KB Output isn't correct
41 Incorrect 1 ms 724 KB Output isn't correct
42 Incorrect 2 ms 2388 KB Output isn't correct
43 Runtime error 156 ms 131072 KB Execution killed with signal 9
44 Incorrect 10 ms 12756 KB Output isn't correct
45 Runtime error 151 ms 131072 KB Execution killed with signal 9
46 Runtime error 144 ms 131072 KB Execution killed with signal 9
47 Runtime error 152 ms 131072 KB Execution killed with signal 9
48 Runtime error 157 ms 131072 KB Execution killed with signal 9
49 Runtime error 157 ms 131072 KB Execution killed with signal 9
50 Runtime error 159 ms 131076 KB Execution killed with signal 9
51 Runtime error 155 ms 131072 KB Execution killed with signal 9
52 Runtime error 156 ms 131072 KB Execution killed with signal 9
53 Runtime error 165 ms 131072 KB Execution killed with signal 9
54 Incorrect 149 ms 126616 KB Output isn't correct
55 Incorrect 149 ms 119152 KB Output isn't correct
56 Runtime error 170 ms 131072 KB Execution killed with signal 9
57 Incorrect 131 ms 97144 KB Output isn't correct
58 Incorrect 140 ms 109024 KB Output isn't correct
59 Incorrect 161 ms 101064 KB Output isn't correct
60 Runtime error 149 ms 131072 KB Execution killed with signal 9
61 Runtime error 159 ms 131072 KB Execution killed with signal 9
62 Runtime error 157 ms 131072 KB Execution killed with signal 9
63 Runtime error 155 ms 131072 KB Execution killed with signal 9
64 Correct 136 ms 103972 KB Output is correct
65 Runtime error 156 ms 131072 KB Execution killed with signal 9
66 Runtime error 156 ms 131072 KB Execution killed with signal 9
67 Runtime error 154 ms 131072 KB Execution killed with signal 9
68 Runtime error 152 ms 131072 KB Execution killed with signal 9
69 Incorrect 140 ms 96760 KB Output isn't correct
70 Incorrect 77 ms 35720 KB Output isn't correct
71 Incorrect 118 ms 71500 KB Output isn't correct
72 Incorrect 128 ms 91780 KB Output isn't correct
73 Incorrect 131 ms 96396 KB Output isn't correct
74 Incorrect 132 ms 96804 KB Output isn't correct
75 Incorrect 135 ms 101560 KB Output isn't correct
76 Incorrect 135 ms 106012 KB Output isn't correct
77 Incorrect 144 ms 108716 KB Output isn't correct
78 Incorrect 139 ms 108292 KB Output isn't correct
79 Incorrect 92 ms 23336 KB Output isn't correct
80 Incorrect 94 ms 26016 KB Output isn't correct
81 Incorrect 97 ms 29604 KB Output isn't correct
82 Incorrect 139 ms 115748 KB Output isn't correct
83 Incorrect 142 ms 115620 KB Output isn't correct
84 Incorrect 85 ms 13984 KB Output isn't correct
85 Incorrect 134 ms 110120 KB Output isn't correct
86 Runtime error 153 ms 131072 KB Execution killed with signal 9
87 Incorrect 131 ms 105776 KB Output isn't correct
88 Incorrect 139 ms 113448 KB Output isn't correct
89 Runtime error 146 ms 131072 KB Execution killed with signal 9
90 Incorrect 91 ms 74076 KB Output isn't correct
91 Incorrect 145 ms 125092 KB Output isn't correct
92 Runtime error 150 ms 131072 KB Execution killed with signal 9
93 Runtime error 161 ms 131072 KB Execution killed with signal 9
94 Runtime error 152 ms 131072 KB Execution killed with signal 9
95 Incorrect 149 ms 116000 KB Output isn't correct
96 Incorrect 144 ms 115364 KB Output isn't correct
97 Runtime error 157 ms 131072 KB Execution killed with signal 9
98 Incorrect 142 ms 115112 KB Output isn't correct
99 Runtime error 152 ms 131072 KB Execution killed with signal 9
100 Runtime error 158 ms 131072 KB Execution killed with signal 9