Submission #528497

#TimeUsernameProblemLanguageResultExecution timeMemory
528497MilosMilutinovicBomb (IZhO17_bomb)C++14
24 / 100
99 ms31044 KiB
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

int n, m, a[2505][2505];

int main()
{
  scanf("%d%d", &n, &m);
  rep1(i, n) {
    char s[m + 1];
    scanf("%s", s + 1);
    rep1(j, m) a[i][j] = s[j] - '0';
  }
  int ansx = 1e9, ansy = 1e9;
  rep1(i, n) rep1(j, m) {
    if(a[i][j] == 0) continue;
    int ptr = j;
    while(ptr < m && a[i][ptr + 1] == 1) ptr ++;
    ansx = min(ansx, ptr - j + 1);
    j = ptr;
  }
  rep1(j, m) rep1(i, n) {
    if(a[i][j] == 0) continue;
    int ptr = i;
    while(ptr < n && a[ptr + 1][j] == 1) ptr ++;
    ansy = min(ansy, ptr - i + 1);
    i = ptr;
  }
  printf("%d", ansx * ansy);
}

Compilation message (stderr)

bomb.cpp: In function 'int main()':
bomb.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d%d", &n, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~
bomb.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%s", s + 1);
      |     ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...