# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1128716 | raisel | Bomb (IZhO17_bomb) | C++20 | 3 ms | 584 KiB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#define forn for(int i=1;i<=n;i++)
#define Yes cout<<"YES\n"
#define No cout<<"NO\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define pb push_back
#define sp setprecision
#define int long long
#define ll long long
#define nn '\n'
using namespace std;
const int N=2502;
const int MOD=1e9+7;
char a[N][N];
string ab="abcdefghijklmnopqrstuvwxyz";
int binpow(int n, int k) {
int ans = 1;
while (k > 0) {
if (k % 2 == 1) {
ans = (ans * n) % MOD;
}
n = (n * n) % MOD;
k /= 2;
}
return ans;
}
int n,m;
string s;
void al(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
int cnt=0;
vector<int>v;
a[n+1][m]=a[n][m];
a[n][m+1]=a[n][m];
for(int i=1;i<=n+1;i++){
for(int j=1;j<=m+1;j++){
if(a[i][j]=='1') cnt++;
else {
if(cnt>0) v.pb(cnt);
cnt=0;
}
}
}
int x=v[0];
for(auto i:v){
int g=__gcd(x,i);
x=g;
}
cout<<x;
}
signed main(){
freopen("bomb.in","r",stdin);
freopen("bomb.out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t=1;
// cin>>t;
while(t--) {
al();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |