#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f[2509][2509];
string s;
int gc(int q, int w){
if(q>w) swap(q,w);
if(q==0) return w;
return gc(w%q,q);
}
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=0;
for(c=1; c<=b; c++){
if(f[1][c]==1){
d++;
}else{
if(d!=0) e=gc(e,d);
d=0;
}
}
if(d!=0) e=gc(e,d);
}
if(b==1){
d=0;
e=0;
for(c=1; c<=a; c++){
if(f[c][1]==1){
d++;
}else{
if(d!=0) e=gc(e,d);
d=0;
}
}
if(d!=0) e=gc(e,d);
}
cout<<e;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
3 |
Incorrect |
10 ms |
10360 KB |
Output isn't correct |
4 |
Incorrect |
12 ms |
10360 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't 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 |
504 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 |
632 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
19 |
Incorrect |
2 ms |
760 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
760 KB |
Output isn't correct |
21 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
22 |
Incorrect |
2 ms |
764 KB |
Output isn't correct |
23 |
Incorrect |
3 ms |
760 KB |
Output isn't correct |
24 |
Incorrect |
2 ms |
636 KB |
Output isn't correct |
25 |
Incorrect |
2 ms |
760 KB |
Output isn't correct |
26 |
Incorrect |
3 ms |
760 KB |
Output isn't correct |
27 |
Incorrect |
4 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 |
5 ms |
3064 KB |
Output isn't correct |
31 |
Incorrect |
4 ms |
2424 KB |
Output isn't correct |
32 |
Incorrect |
4 ms |
2680 KB |
Output isn't correct |
33 |
Incorrect |
5 ms |
3064 KB |
Output isn't correct |
34 |
Incorrect |
4 ms |
2168 KB |
Output isn't correct |
35 |
Incorrect |
4 ms |
3112 KB |
Output isn't correct |
36 |
Incorrect |
4 ms |
3064 KB |
Output isn't correct |
37 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
38 |
Incorrect |
35 ms |
27896 KB |
Output isn't correct |
39 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
40 |
Incorrect |
13 ms |
7672 KB |
Output isn't correct |
41 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
42 |
Incorrect |
2 ms |
760 KB |
Output isn't correct |
43 |
Incorrect |
34 ms |
27772 KB |
Output isn't correct |
44 |
Incorrect |
4 ms |
3064 KB |
Output isn't correct |
45 |
Incorrect |
35 ms |
28024 KB |
Output isn't correct |
46 |
Incorrect |
35 ms |
27896 KB |
Output isn't correct |
47 |
Incorrect |
36 ms |
28136 KB |
Output isn't correct |
48 |
Incorrect |
35 ms |
28192 KB |
Output isn't correct |
49 |
Incorrect |
35 ms |
28408 KB |
Output isn't correct |
50 |
Incorrect |
35 ms |
28792 KB |
Output isn't correct |
51 |
Incorrect |
35 ms |
28880 KB |
Output isn't correct |
52 |
Incorrect |
35 ms |
28792 KB |
Output isn't correct |
53 |
Incorrect |
35 ms |
29432 KB |
Output isn't correct |
54 |
Incorrect |
35 ms |
28920 KB |
Output isn't correct |
55 |
Incorrect |
36 ms |
28920 KB |
Output isn't correct |
56 |
Incorrect |
36 ms |
28920 KB |
Output isn't correct |
57 |
Incorrect |
35 ms |
28920 KB |
Output isn't correct |
58 |
Incorrect |
35 ms |
29048 KB |
Output isn't correct |
59 |
Incorrect |
35 ms |
28464 KB |
Output isn't correct |
60 |
Incorrect |
35 ms |
28792 KB |
Output isn't correct |
61 |
Incorrect |
35 ms |
28792 KB |
Output isn't correct |
62 |
Incorrect |
35 ms |
28988 KB |
Output isn't correct |
63 |
Incorrect |
34 ms |
27900 KB |
Output isn't correct |
64 |
Incorrect |
36 ms |
28144 KB |
Output isn't correct |
65 |
Incorrect |
37 ms |
28536 KB |
Output isn't correct |
66 |
Incorrect |
34 ms |
27384 KB |
Output isn't correct |
67 |
Incorrect |
35 ms |
27640 KB |
Output isn't correct |
68 |
Incorrect |
35 ms |
28156 KB |
Output isn't correct |
69 |
Incorrect |
35 ms |
27640 KB |
Output isn't correct |
70 |
Incorrect |
26 ms |
22520 KB |
Output isn't correct |
71 |
Incorrect |
34 ms |
28552 KB |
Output isn't correct |
72 |
Incorrect |
35 ms |
28536 KB |
Output isn't correct |
73 |
Incorrect |
34 ms |
27384 KB |
Output isn't correct |
74 |
Incorrect |
34 ms |
27280 KB |
Output isn't correct |
75 |
Incorrect |
34 ms |
27384 KB |
Output isn't correct |
76 |
Incorrect |
34 ms |
27304 KB |
Output isn't correct |
77 |
Incorrect |
34 ms |
27384 KB |
Output isn't correct |
78 |
Incorrect |
34 ms |
27364 KB |
Output isn't correct |
79 |
Incorrect |
34 ms |
27256 KB |
Output isn't correct |
80 |
Incorrect |
34 ms |
27256 KB |
Output isn't correct |
81 |
Incorrect |
34 ms |
27256 KB |
Output isn't correct |
82 |
Incorrect |
34 ms |
27516 KB |
Output isn't correct |
83 |
Incorrect |
34 ms |
27512 KB |
Output isn't correct |
84 |
Incorrect |
34 ms |
27512 KB |
Output isn't correct |
85 |
Incorrect |
34 ms |
27512 KB |
Output isn't correct |
86 |
Incorrect |
35 ms |
27512 KB |
Output isn't correct |
87 |
Incorrect |
35 ms |
27640 KB |
Output isn't correct |
88 |
Incorrect |
35 ms |
27864 KB |
Output isn't correct |
89 |
Incorrect |
35 ms |
27772 KB |
Output isn't correct |
90 |
Incorrect |
26 ms |
22648 KB |
Output isn't correct |
91 |
Incorrect |
35 ms |
27512 KB |
Output isn't correct |
92 |
Incorrect |
35 ms |
27768 KB |
Output isn't correct |
93 |
Incorrect |
35 ms |
28152 KB |
Output isn't correct |
94 |
Incorrect |
35 ms |
28152 KB |
Output isn't correct |
95 |
Incorrect |
35 ms |
28152 KB |
Output isn't correct |
96 |
Incorrect |
35 ms |
28280 KB |
Output isn't correct |
97 |
Incorrect |
34 ms |
28280 KB |
Output isn't correct |
98 |
Incorrect |
34 ms |
28664 KB |
Output isn't correct |
99 |
Incorrect |
34 ms |
28712 KB |
Output isn't correct |
100 |
Incorrect |
34 ms |
28664 KB |
Output isn't correct |