# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38412 | daniel_02 | Bomb (IZhO17_bomb) | C++14 | 416 ms | 8612 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;
char a[2599][2599];
int ans;
int mx = 1e9;
int main()
{
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++)
{
scanf("\n");
for (int j = 0; j < m; j++)
{
scanf("%c",&a[i][j]);
}
}
if (n > 1 && m > 1)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (a[i][j] == '0')
{
if (ans)
mx = max(mx, ans);
ans = 0;
}
else
{
ans++;
}
}
}
cout << ans;
return 0;
}
for (int i = 0; i < max(n, m); i++)
{
int j = min(n, m) - 1;
if (j == n - 1)
{
if (a[j][i] == '1')
{
ans++;
}
else if (ans)
mx = min(mx, ans),ans = 0;
}
else
{
if (a[i][j] == '1')
{
ans++;
}
else if (ans)
mx = min(mx, ans),ans = 0;
}
}
if (ans)
mx = min(mx, ans);
cout << mx;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |