# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
171073 | mosiashvililuka | Bomb (IZhO17_bomb) | C++14 | 37 ms | 29432 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |