Submission #877352

# Submission time Handle Problem Language Result Execution time Memory
877352 2023-11-23T07:45:34 Z marcid Bomb (IZhO17_bomb) C++17
24 / 100
245 ms 10116 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2501;
char field[maxn][maxn];
int mn1=maxn,mn2=maxn;
int count(string s) {
	int cnt = 1; int best = s.size();
	bool ret = false; 
	for (int i = 0; i < s.size(); i++) {
		if (s[i]=='1') ret=true;
	} for (int i = 1; i < s.size(); i++) {
		if (s[i]=='1' && s[i-1]=='1') cnt++;
		else if(s[i-1]=='1' && s[i]=='0') {best=min(best,cnt);cnt=1;}
	}
	if (s.size()>1 && s[s.size()-1]=='1' && s[s.size()-2]=='0') best=1;
	return (ret ? (best) : 0);
}

signed main() {
	int n,m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> field[i][j];
		}
	} for (int i = 1; i <= n; i++) {
		string t="0";
		for (int j = 1; j <= m; j++) t+=field[i][j];
		int x = count(t+'0');
		if (x>0) mn1=min(mn1,x);
	} for (int j = 1; j <= m; j++) {
		string t="0";
		for (int i = 1; i <= n; i++) t+=field[i][j];
		int x = count(t+'0');
		if (x>0) mn2=min(mn2, x);
	} 
	cout << ((maxn==mn1 || maxn==mn2) ? 0 : mn1*mn2) <<'\n';
}

Compilation message

bomb.cpp: In function 'long long int count(std::string)':
bomb.cpp:10:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for (int i = 0; i < s.size(); i++) {
      |                  ~~^~~~~~~~~~
bomb.cpp:12:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  } for (int i = 1; i < s.size(); i++) {
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 6416 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 444 KB Output isn't correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Incorrect 1 ms 348 KB Output isn't correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Incorrect 0 ms 604 KB Output isn't correct
19 Incorrect 1 ms 2652 KB Output isn't correct
20 Incorrect 1 ms 2652 KB Output isn't correct
21 Incorrect 0 ms 348 KB Output isn't correct
22 Incorrect 1 ms 2652 KB Output isn't correct
23 Incorrect 1 ms 2652 KB Output isn't correct
24 Incorrect 1 ms 2652 KB Output isn't correct
25 Incorrect 1 ms 2652 KB Output isn't correct
26 Correct 1 ms 2652 KB Output is correct
27 Correct 4 ms 2648 KB Output is correct
28 Incorrect 5 ms 2652 KB Output isn't correct
29 Incorrect 5 ms 2760 KB Output isn't correct
30 Incorrect 7 ms 2696 KB Output isn't correct
31 Incorrect 6 ms 2652 KB Output isn't correct
32 Incorrect 6 ms 2784 KB Output isn't correct
33 Incorrect 8 ms 2872 KB Output isn't correct
34 Incorrect 4 ms 2652 KB Output isn't correct
35 Incorrect 8 ms 2652 KB Output isn't correct
36 Correct 8 ms 2652 KB Output is correct
37 Incorrect 0 ms 348 KB Output isn't correct
38 Correct 231 ms 9812 KB Output is correct
39 Incorrect 0 ms 348 KB Output isn't correct
40 Incorrect 29 ms 3160 KB Output isn't correct
41 Incorrect 0 ms 348 KB Output isn't correct
42 Incorrect 1 ms 2652 KB Output isn't correct
43 Correct 228 ms 9724 KB Output is correct
44 Incorrect 8 ms 2648 KB Output isn't correct
45 Incorrect 229 ms 9868 KB Output isn't correct
46 Correct 229 ms 9872 KB Output is correct
47 Incorrect 229 ms 9808 KB Output isn't correct
48 Incorrect 245 ms 9944 KB Output isn't correct
49 Correct 227 ms 9816 KB Output is correct
50 Incorrect 234 ms 9732 KB Output isn't correct
51 Incorrect 233 ms 9724 KB Output isn't correct
52 Incorrect 227 ms 9808 KB Output isn't correct
53 Incorrect 238 ms 9812 KB Output isn't correct
54 Incorrect 243 ms 9752 KB Output isn't correct
55 Incorrect 229 ms 9708 KB Output isn't correct
56 Correct 226 ms 9640 KB Output is correct
57 Incorrect 227 ms 9804 KB Output isn't correct
58 Incorrect 228 ms 9808 KB Output isn't correct
59 Incorrect 239 ms 9860 KB Output isn't correct
60 Correct 240 ms 9804 KB Output is correct
61 Correct 229 ms 9808 KB Output is correct
62 Correct 231 ms 9948 KB Output is correct
63 Correct 226 ms 9808 KB Output is correct
64 Correct 229 ms 9672 KB Output is correct
65 Incorrect 227 ms 9872 KB Output isn't correct
66 Incorrect 237 ms 9808 KB Output isn't correct
67 Incorrect 230 ms 10116 KB Output isn't correct
68 Incorrect 228 ms 9800 KB Output isn't correct
69 Incorrect 233 ms 9728 KB Output isn't correct
70 Incorrect 150 ms 7880 KB Output isn't correct
71 Incorrect 233 ms 9808 KB Output isn't correct
72 Incorrect 227 ms 9808 KB Output isn't correct
73 Incorrect 237 ms 9848 KB Output isn't correct
74 Incorrect 227 ms 9808 KB Output isn't correct
75 Incorrect 231 ms 9808 KB Output isn't correct
76 Incorrect 233 ms 9808 KB Output isn't correct
77 Incorrect 234 ms 9644 KB Output isn't correct
78 Incorrect 227 ms 9808 KB Output isn't correct
79 Incorrect 231 ms 9812 KB Output isn't correct
80 Incorrect 228 ms 9696 KB Output isn't correct
81 Incorrect 232 ms 10064 KB Output isn't correct
82 Incorrect 226 ms 9812 KB Output isn't correct
83 Incorrect 229 ms 9808 KB Output isn't correct
84 Incorrect 235 ms 10068 KB Output isn't correct
85 Incorrect 226 ms 9628 KB Output isn't correct
86 Incorrect 227 ms 9632 KB Output isn't correct
87 Incorrect 234 ms 10116 KB Output isn't correct
88 Incorrect 240 ms 9872 KB Output isn't correct
89 Incorrect 230 ms 9808 KB Output isn't correct
90 Incorrect 146 ms 7504 KB Output isn't correct
91 Incorrect 230 ms 9688 KB Output isn't correct
92 Incorrect 228 ms 9668 KB Output isn't correct
93 Incorrect 234 ms 9796 KB Output isn't correct
94 Incorrect 228 ms 9816 KB Output isn't correct
95 Incorrect 227 ms 9804 KB Output isn't correct
96 Incorrect 227 ms 9812 KB Output isn't correct
97 Incorrect 231 ms 9816 KB Output isn't correct
98 Incorrect 236 ms 9948 KB Output isn't correct
99 Incorrect 227 ms 9660 KB Output isn't correct
100 Incorrect 233 ms 9868 KB Output isn't correct