#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f[2509][2509];
string s;
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a>>b;
for(c=1; c<=a; c++){
cin>>s;
for(d=1; d<=b; d++){
f[c][d]=s[d-1]-'0';
}
}
if(a==1){
d=0;
e=b;
for(c=1; c<=b; c++){
if(f[1][c]==1){
d++;
}else{
if(d!=0) e=min(d,e);
d=0;
}
}
if(d!=0) e=min(d,e);
}
if(b==1){
d=0;
e=a;
for(c=1; c<=a; c++){
if(f[c][1]==1){
d++;
}else{
if(d!=0) e=min(d,e);
d=0;
}
}
if(d!=0) e=min(d,e);
}
cout<<e;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
10 ms |
10360 KB |
Output is correct |
4 |
Correct |
10 ms |
10360 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
13 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
14 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
636 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
19 |
Incorrect |
2 ms |
776 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
760 KB |
Output isn't correct |
21 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
22 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
23 |
Incorrect |
2 ms |
760 KB |
Output isn't correct |
24 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
25 |
Incorrect |
2 ms |
760 KB |
Output isn't correct |
26 |
Incorrect |
2 ms |
760 KB |
Output isn't correct |
27 |
Incorrect |
3 ms |
1912 KB |
Output isn't correct |
28 |
Incorrect |
4 ms |
2040 KB |
Output isn't correct |
29 |
Incorrect |
4 ms |
2552 KB |
Output isn't correct |
30 |
Incorrect |
4 ms |
3064 KB |
Output isn't correct |
31 |
Incorrect |
4 ms |
2424 KB |
Output isn't correct |
32 |
Incorrect |
4 ms |
2808 KB |
Output isn't correct |
33 |
Incorrect |
4 ms |
3192 KB |
Output isn't correct |
34 |
Incorrect |
3 ms |
2168 KB |
Output isn't correct |
35 |
Incorrect |
4 ms |
3064 KB |
Output isn't correct |
36 |
Incorrect |
4 ms |
3064 KB |
Output isn't correct |
37 |
Incorrect |
2 ms |
420 KB |
Output isn't correct |
38 |
Incorrect |
34 ms |
25772 KB |
Output isn't correct |
39 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
40 |
Incorrect |
9 ms |
7288 KB |
Output isn't correct |
41 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
42 |
Incorrect |
3 ms |
760 KB |
Output isn't correct |
43 |
Incorrect |
34 ms |
25720 KB |
Output isn't correct |
44 |
Incorrect |
4 ms |
3192 KB |
Output isn't correct |
45 |
Incorrect |
34 ms |
25564 KB |
Output isn't correct |
46 |
Incorrect |
34 ms |
25592 KB |
Output isn't correct |
47 |
Incorrect |
35 ms |
25720 KB |
Output isn't correct |
48 |
Incorrect |
34 ms |
25592 KB |
Output isn't correct |
49 |
Incorrect |
34 ms |
25464 KB |
Output isn't correct |
50 |
Incorrect |
34 ms |
25532 KB |
Output isn't correct |
51 |
Incorrect |
35 ms |
25592 KB |
Output isn't correct |
52 |
Incorrect |
34 ms |
25464 KB |
Output isn't correct |
53 |
Incorrect |
34 ms |
25592 KB |
Output isn't correct |
54 |
Incorrect |
35 ms |
25592 KB |
Output isn't correct |
55 |
Incorrect |
34 ms |
25540 KB |
Output isn't correct |
56 |
Incorrect |
34 ms |
25464 KB |
Output isn't correct |
57 |
Incorrect |
34 ms |
25464 KB |
Output isn't correct |
58 |
Incorrect |
34 ms |
25592 KB |
Output isn't correct |
59 |
Incorrect |
35 ms |
25492 KB |
Output isn't correct |
60 |
Incorrect |
42 ms |
25468 KB |
Output isn't correct |
61 |
Incorrect |
34 ms |
25464 KB |
Output isn't correct |
62 |
Incorrect |
34 ms |
25464 KB |
Output isn't correct |
63 |
Incorrect |
35 ms |
25660 KB |
Output isn't correct |
64 |
Incorrect |
34 ms |
25592 KB |
Output isn't correct |
65 |
Incorrect |
34 ms |
25524 KB |
Output isn't correct |
66 |
Incorrect |
34 ms |
25596 KB |
Output isn't correct |
67 |
Incorrect |
34 ms |
25448 KB |
Output isn't correct |
68 |
Incorrect |
34 ms |
25464 KB |
Output isn't correct |
69 |
Incorrect |
34 ms |
25468 KB |
Output isn't correct |
70 |
Incorrect |
26 ms |
20628 KB |
Output isn't correct |
71 |
Incorrect |
34 ms |
25564 KB |
Output isn't correct |
72 |
Incorrect |
34 ms |
25464 KB |
Output isn't correct |
73 |
Incorrect |
34 ms |
25720 KB |
Output isn't correct |
74 |
Incorrect |
34 ms |
25596 KB |
Output isn't correct |
75 |
Incorrect |
34 ms |
25592 KB |
Output isn't correct |
76 |
Incorrect |
34 ms |
25564 KB |
Output isn't correct |
77 |
Incorrect |
34 ms |
25592 KB |
Output isn't correct |
78 |
Incorrect |
34 ms |
25464 KB |
Output isn't correct |
79 |
Incorrect |
34 ms |
25720 KB |
Output isn't correct |
80 |
Incorrect |
34 ms |
25720 KB |
Output isn't correct |
81 |
Incorrect |
34 ms |
25720 KB |
Output isn't correct |
82 |
Incorrect |
34 ms |
25592 KB |
Output isn't correct |
83 |
Incorrect |
34 ms |
25356 KB |
Output isn't correct |
84 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
85 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
86 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
87 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
88 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
89 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
90 |
Incorrect |
25 ms |
20472 KB |
Output isn't correct |
91 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
92 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
93 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
94 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
95 |
Incorrect |
34 ms |
25372 KB |
Output isn't correct |
96 |
Incorrect |
35 ms |
25336 KB |
Output isn't correct |
97 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
98 |
Incorrect |
34 ms |
25284 KB |
Output isn't correct |
99 |
Incorrect |
34 ms |
25336 KB |
Output isn't correct |
100 |
Incorrect |
34 ms |
25288 KB |
Output isn't correct |