Submission #505738

# Submission time Handle Problem Language Result Execution time Memory
505738 2022-01-11T07:24:04 Z shmad Bomb (IZhO17_bomb) C++17
0 / 100
1000 ms 376 KB
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define dbg(x) cerr << #x << " = " << x << '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vvi = vt< vt<int> >;

const int N = 1e6 + 5, mod = 1e9 + 7, inf = 1e18 + 7, B = 500, LIM = (1ll << 60);
const double eps = 1e-6;

char c[2501][2501];

void solve () {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) cin >> c[i][j];
	}
	int a = inf, b = inf;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (c[i][j] == '1') {
				int k = j;
				while (k + 1 <= m && c[i][k + 1] == '1') k++;
				a = min(a, k - j + 1);
				j = k + 1;
			}
		}
	}
	for (int j = 1; j <= m; j++) {
		for (int i = 1; i <= n; i++) {
			if (c[i][j] == '1') {
				int k = i;
				while (k + 1 <= n && c[k + 1][j] == '1') k++;
				b = min(b, k - i + 1);
				i = k + 1;
			}
		}
	}
	int ans = a * b;
	cout << ans;
	cout << '\n';
}

bool testcases = 0;
                  
signed main() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
    cin.tie(0) -> sync_with_stdio(0);
    int test = 1;
    if (testcases) cin >> test;
    for (int cs = 1; cs <= test; cs++) {
        solve();
    }
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:64:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |  freopen("input.in", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bomb.cpp:65:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |  freopen("output.out", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 332 KB Time limit exceeded
2 Execution timed out 1088 ms 332 KB Time limit exceeded
3 Execution timed out 1068 ms 332 KB Time limit exceeded
4 Execution timed out 1072 ms 332 KB Time limit exceeded
5 Execution timed out 1088 ms 332 KB Time limit exceeded
6 Execution timed out 1085 ms 332 KB Time limit exceeded
7 Execution timed out 1067 ms 332 KB Time limit exceeded
8 Execution timed out 1085 ms 332 KB Time limit exceeded
9 Execution timed out 1084 ms 332 KB Time limit exceeded
10 Execution timed out 1095 ms 332 KB Time limit exceeded
11 Execution timed out 1085 ms 332 KB Time limit exceeded
12 Execution timed out 1087 ms 332 KB Time limit exceeded
13 Execution timed out 1070 ms 332 KB Time limit exceeded
14 Execution timed out 1088 ms 332 KB Time limit exceeded
15 Execution timed out 1093 ms 332 KB Time limit exceeded
16 Execution timed out 1091 ms 332 KB Time limit exceeded
17 Execution timed out 1094 ms 336 KB Time limit exceeded
18 Execution timed out 1068 ms 332 KB Time limit exceeded
19 Execution timed out 1082 ms 332 KB Time limit exceeded
20 Execution timed out 1090 ms 332 KB Time limit exceeded
21 Execution timed out 1093 ms 332 KB Time limit exceeded
22 Execution timed out 1095 ms 332 KB Time limit exceeded
23 Execution timed out 1096 ms 332 KB Time limit exceeded
24 Execution timed out 1097 ms 332 KB Time limit exceeded
25 Execution timed out 1085 ms 332 KB Time limit exceeded
26 Execution timed out 1078 ms 332 KB Time limit exceeded
27 Execution timed out 1068 ms 332 KB Time limit exceeded
28 Execution timed out 1049 ms 332 KB Time limit exceeded
29 Execution timed out 1093 ms 332 KB Time limit exceeded
30 Execution timed out 1093 ms 332 KB Time limit exceeded
31 Execution timed out 1094 ms 332 KB Time limit exceeded
32 Execution timed out 1089 ms 332 KB Time limit exceeded
33 Execution timed out 1093 ms 332 KB Time limit exceeded
34 Execution timed out 1076 ms 332 KB Time limit exceeded
35 Execution timed out 1082 ms 332 KB Time limit exceeded
36 Execution timed out 1087 ms 332 KB Time limit exceeded
37 Execution timed out 1087 ms 332 KB Time limit exceeded
38 Execution timed out 1084 ms 332 KB Time limit exceeded
39 Execution timed out 1081 ms 332 KB Time limit exceeded
40 Execution timed out 1074 ms 332 KB Time limit exceeded
41 Execution timed out 1073 ms 332 KB Time limit exceeded
42 Execution timed out 1078 ms 332 KB Time limit exceeded
43 Execution timed out 1088 ms 332 KB Time limit exceeded
44 Execution timed out 1062 ms 332 KB Time limit exceeded
45 Execution timed out 1063 ms 332 KB Time limit exceeded
46 Execution timed out 1095 ms 332 KB Time limit exceeded
47 Execution timed out 1081 ms 332 KB Time limit exceeded
48 Execution timed out 1092 ms 332 KB Time limit exceeded
49 Execution timed out 1083 ms 332 KB Time limit exceeded
50 Execution timed out 1094 ms 332 KB Time limit exceeded
51 Execution timed out 1088 ms 332 KB Time limit exceeded
52 Execution timed out 1081 ms 332 KB Time limit exceeded
53 Execution timed out 1067 ms 332 KB Time limit exceeded
54 Execution timed out 1094 ms 332 KB Time limit exceeded
55 Execution timed out 1098 ms 332 KB Time limit exceeded
56 Execution timed out 1088 ms 332 KB Time limit exceeded
57 Execution timed out 1091 ms 332 KB Time limit exceeded
58 Execution timed out 1097 ms 332 KB Time limit exceeded
59 Execution timed out 1094 ms 332 KB Time limit exceeded
60 Execution timed out 1099 ms 332 KB Time limit exceeded
61 Execution timed out 1083 ms 332 KB Time limit exceeded
62 Execution timed out 1082 ms 332 KB Time limit exceeded
63 Execution timed out 1095 ms 332 KB Time limit exceeded
64 Execution timed out 1066 ms 332 KB Time limit exceeded
65 Execution timed out 1087 ms 332 KB Time limit exceeded
66 Execution timed out 1089 ms 332 KB Time limit exceeded
67 Execution timed out 1046 ms 332 KB Time limit exceeded
68 Execution timed out 1092 ms 332 KB Time limit exceeded
69 Execution timed out 1078 ms 332 KB Time limit exceeded
70 Execution timed out 1063 ms 332 KB Time limit exceeded
71 Execution timed out 1088 ms 332 KB Time limit exceeded
72 Execution timed out 1091 ms 332 KB Time limit exceeded
73 Execution timed out 1087 ms 332 KB Time limit exceeded
74 Execution timed out 1097 ms 332 KB Time limit exceeded
75 Execution timed out 1088 ms 332 KB Time limit exceeded
76 Execution timed out 1084 ms 332 KB Time limit exceeded
77 Execution timed out 1083 ms 332 KB Time limit exceeded
78 Execution timed out 1101 ms 332 KB Time limit exceeded
79 Execution timed out 1097 ms 332 KB Time limit exceeded
80 Execution timed out 1090 ms 332 KB Time limit exceeded
81 Execution timed out 1090 ms 332 KB Time limit exceeded
82 Execution timed out 1072 ms 332 KB Time limit exceeded
83 Execution timed out 1089 ms 332 KB Time limit exceeded
84 Execution timed out 1095 ms 332 KB Time limit exceeded
85 Execution timed out 1088 ms 332 KB Time limit exceeded
86 Execution timed out 1089 ms 332 KB Time limit exceeded
87 Execution timed out 1077 ms 332 KB Time limit exceeded
88 Execution timed out 1087 ms 332 KB Time limit exceeded
89 Execution timed out 1099 ms 332 KB Time limit exceeded
90 Execution timed out 1090 ms 332 KB Time limit exceeded
91 Execution timed out 1095 ms 332 KB Time limit exceeded
92 Execution timed out 1082 ms 332 KB Time limit exceeded
93 Execution timed out 1088 ms 332 KB Time limit exceeded
94 Execution timed out 1088 ms 332 KB Time limit exceeded
95 Execution timed out 1096 ms 332 KB Time limit exceeded
96 Execution timed out 1099 ms 332 KB Time limit exceeded
97 Execution timed out 1064 ms 332 KB Time limit exceeded
98 Execution timed out 1078 ms 332 KB Time limit exceeded
99 Execution timed out 1089 ms 376 KB Time limit exceeded
100 Execution timed out 1091 ms 332 KB Time limit exceeded