Submission #171073

#TimeUsernameProblemLanguageResultExecution timeMemory
171073mosiashvililukaBomb (IZhO17_bomb)C++14
0 / 100
37 ms29432 KiB
#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 timeMemoryGrader output
Fetching results...