Submission #38408

#TimeUsernameProblemLanguageResultExecution timeMemory
38408daniel_02Bomb (IZhO17_bomb)C++14
8 / 100
0 ms8612 KiB
#include <bits/stdc++.h>



using namespace std;

char a[2599][2599];

int ans;
int mx = 1e9;
bool fl;
int main()
{
   int n, m;
   cin >> n >> m;
   if (n > 1 && m > 1)
   {
       cout << m;
       return 0;
   }
   for (int i = 0; i < n; i++)
   {
       scanf("\n");
       for (int j = 0; j < m; j++)
       {
           scanf("%c",&a[i][j]);
           if (a[i][j] == '1')fl = 1;
       }
   }

   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)

bomb.cpp: In function 'int main()':
bomb.cpp:23:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
        scanf("\n");
                   ^
bomb.cpp:26:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
            scanf("%c",&a[i][j]);
                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...