Submission #388275

# Submission time Handle Problem Language Result Execution time Memory
388275 2021-04-10T18:08:18 Z patrikpavic2 Bomb (IZhO17_bomb) C++17
15 / 100
1000 ms 12640 KB
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 2505;

int n, m;
char s[N][N];

int main(){
	//freopen("bomb.in", "r", stdin);
	//freopen("bomb.out", "w", stdout);
	scanf("%d%d", &n, &m);
	for(int i = 0;i < n;i++)
		for(int j = 0;j < m;j++)
			scanf(" %c", &s[i][j]);
	int ansi = n, ansj = m;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			if(s[i][j] != '1') continue;
			int il = i, ir = i;
			int jl = j, jr = j;
			while(il > 0 && s[il - 1][j] == '1') il--;
			while(ir + 1 < n && s[ir + 1][j] == '1') ir++;
			while(jl > 0 && s[i][jl - 1] == '1') jl--;
			while(jr + 1 < m && s[i][jr + 1] == '1') jr++;
			ansi = min(ansi, ir - il + 1);
			ansj = min(ansj, jr - jl + 1);
		}
	}
	printf("%d\n", ansi * ansj);
	return 0;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
bomb.cpp:17:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |    scanf(" %c", &s[i][j]);
      |    ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 6 ms 6348 KB Output is correct
4 Correct 5 ms 6404 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Incorrect 0 ms 332 KB Output isn't correct
9 Incorrect 0 ms 332 KB Output isn't correct
10 Incorrect 0 ms 204 KB Output isn't correct
11 Incorrect 1 ms 332 KB Output isn't correct
12 Incorrect 0 ms 204 KB Output isn't correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Incorrect 0 ms 332 KB Output isn't correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 420 KB Output is correct
18 Incorrect 1 ms 460 KB Output isn't correct
19 Incorrect 1 ms 460 KB Output isn't correct
20 Incorrect 1 ms 460 KB Output isn't correct
21 Incorrect 1 ms 332 KB Output isn't correct
22 Incorrect 1 ms 460 KB Output isn't correct
23 Incorrect 1 ms 460 KB Output isn't correct
24 Incorrect 1 ms 460 KB Output isn't correct
25 Incorrect 1 ms 420 KB Output isn't correct
26 Correct 3 ms 460 KB Output is correct
27 Correct 36 ms 972 KB Output is correct
28 Incorrect 7 ms 1100 KB Output isn't correct
29 Incorrect 55 ms 1348 KB Output isn't correct
30 Incorrect 20 ms 1488 KB Output isn't correct
31 Incorrect 14 ms 1228 KB Output isn't correct
32 Incorrect 13 ms 1356 KB Output isn't correct
33 Incorrect 29 ms 1580 KB Output isn't correct
34 Incorrect 5 ms 1228 KB Output isn't correct
35 Incorrect 13 ms 1484 KB Output isn't correct
36 Correct 154 ms 1624 KB Output is correct
37 Incorrect 0 ms 284 KB Output isn't correct
38 Execution timed out 1095 ms 12460 KB Time limit exceeded
39 Incorrect 0 ms 332 KB Output isn't correct
40 Incorrect 749 ms 3156 KB Output isn't correct
41 Incorrect 0 ms 332 KB Output isn't correct
42 Incorrect 2 ms 460 KB Output isn't correct
43 Execution timed out 1074 ms 12428 KB Time limit exceeded
44 Incorrect 71 ms 1484 KB Output isn't correct
45 Execution timed out 1081 ms 12460 KB Time limit exceeded
46 Correct 506 ms 12484 KB Output is correct
47 Execution timed out 1090 ms 12484 KB Time limit exceeded
48 Execution timed out 1038 ms 12640 KB Time limit exceeded
49 Execution timed out 1081 ms 12404 KB Time limit exceeded
50 Execution timed out 1086 ms 12480 KB Time limit exceeded
51 Execution timed out 1060 ms 12436 KB Time limit exceeded
52 Execution timed out 1059 ms 12488 KB Time limit exceeded
53 Execution timed out 1092 ms 12464 KB Time limit exceeded
54 Execution timed out 1076 ms 12388 KB Time limit exceeded
55 Execution timed out 1093 ms 12484 KB Time limit exceeded
56 Execution timed out 1092 ms 12428 KB Time limit exceeded
57 Execution timed out 1094 ms 12584 KB Time limit exceeded
58 Execution timed out 1084 ms 12560 KB Time limit exceeded
59 Execution timed out 1097 ms 12468 KB Time limit exceeded
60 Execution timed out 1057 ms 12484 KB Time limit exceeded
61 Execution timed out 1093 ms 12404 KB Time limit exceeded
62 Execution timed out 1078 ms 12596 KB Time limit exceeded
63 Execution timed out 1087 ms 12580 KB Time limit exceeded
64 Execution timed out 1082 ms 12412 KB Time limit exceeded
65 Execution timed out 1086 ms 12444 KB Time limit exceeded
66 Execution timed out 1051 ms 12484 KB Time limit exceeded
67 Execution timed out 1035 ms 12472 KB Time limit exceeded
68 Execution timed out 1075 ms 12420 KB Time limit exceeded
69 Execution timed out 1046 ms 12496 KB Time limit exceeded
70 Incorrect 576 ms 9084 KB Output isn't correct
71 Execution timed out 1042 ms 12480 KB Time limit exceeded
72 Execution timed out 1053 ms 12404 KB Time limit exceeded
73 Execution timed out 1085 ms 12612 KB Time limit exceeded
74 Execution timed out 1088 ms 12452 KB Time limit exceeded
75 Execution timed out 1089 ms 12496 KB Time limit exceeded
76 Execution timed out 1096 ms 12484 KB Time limit exceeded
77 Execution timed out 1089 ms 12484 KB Time limit exceeded
78 Execution timed out 1081 ms 12548 KB Time limit exceeded
79 Incorrect 359 ms 12404 KB Output isn't correct
80 Incorrect 353 ms 12456 KB Output isn't correct
81 Incorrect 443 ms 12488 KB Output isn't correct
82 Execution timed out 1058 ms 12424 KB Time limit exceeded
83 Execution timed out 1083 ms 12488 KB Time limit exceeded
84 Incorrect 372 ms 12408 KB Output isn't correct
85 Execution timed out 1004 ms 12480 KB Time limit exceeded
86 Execution timed out 1062 ms 12448 KB Time limit exceeded
87 Execution timed out 1075 ms 12488 KB Time limit exceeded
88 Execution timed out 1032 ms 12496 KB Time limit exceeded
89 Execution timed out 1090 ms 12504 KB Time limit exceeded
90 Execution timed out 1096 ms 8984 KB Time limit exceeded
91 Execution timed out 1053 ms 12600 KB Time limit exceeded
92 Execution timed out 1069 ms 12436 KB Time limit exceeded
93 Execution timed out 1088 ms 12452 KB Time limit exceeded
94 Execution timed out 1082 ms 12444 KB Time limit exceeded
95 Execution timed out 1084 ms 12612 KB Time limit exceeded
96 Execution timed out 1073 ms 12508 KB Time limit exceeded
97 Execution timed out 1087 ms 12476 KB Time limit exceeded
98 Execution timed out 1070 ms 12584 KB Time limit exceeded
99 Execution timed out 1091 ms 12484 KB Time limit exceeded
100 Execution timed out 1091 ms 12468 KB Time limit exceeded