Submission #51934

#TimeUsernameProblemLanguageResultExecution timeMemory
51934NicksechkoBomb (IZhO17_bomb)C++14
24 / 100
122 ms262144 KiB
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <random>
#include <chrono>
#include <queue>
#include <unordered_map>
//#include <unordered_set>
#include <iomanip>
#include <stack>
#include <ctime>
#include <cassert>
#include <cmath>

#define y1 ups
#define left lll
#define right rrr
#define next nnn
//#define find fff

typedef unsigned long long ull;

using namespace std;

//mt19937_64 twister(chrono::steady_clock().now().time_since_epoch().count());
//mt19937_64 twister(8888);
//
//long long rnd(long long l, long long r)
//{
//    uniform_int_distribution<long long> dis(l, r);
//    return dis(twister);
//}

const int mod = (int)1e9 + 9;
//const int mod[2] = {(int)1e9 + 7, (int)1e9 + 9};
//const int st[2] = {887, 8887};'
const int maxn = 1e6 + 88;
const int inf = 1e9 + 88;
const int logn = 22;
const int maxa = 500*500 + 88;
const int block = 775;
const long long infll = 1e18 + 88;
const char sgl[5] = {'a', 'e', 'i', 'o', 'u'};
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const int knightx[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int knighty[] = {-1, 1, -2, 2, -2, 2, -1, 1};
const int kingx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int kingy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const char sep = 'a' - 1;
const double eps = 1e-9;
const int maxn1 = 1e3 + 88;

//#define int long long

//
//inline int readint()
//{
//    int x = 0;
//    char ch = getchar_unlocked();
//    while (ch < '0' || ch > '9')
//        ch = getchar_unlocked();
//    while (ch >= '0' && ch <= '9')
//    {
//        x = (x << 3) + (x << 1) + ch - '0';
//        ch = getchar_unlocked();
//    }
//    return x;
//}

int a[2588][2588];
string s;

void solve()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    ifstream cin("input.txt");
//    ofstream cout("output.txt");
//    ifstream cin("bootfall.in");
//    ofstream cout("bootfall.out");
    int n, m, i, j, ansv = inf, ansg = inf;
    cin >> n >> m;
    for (i = 0; i < n; i++)
    {
        cin >> s;
        for (j = 0; j < m; j++)
            a[i][j] = s[j] - '0';
    }
    for (i = 0; i < n; i++)
    {
        int last = -1;
        for (j = 0; j < m; j++)
            if (a[i][j] == 0)
            {
                if (j != last + 1)
                    ansg = min(ansg, j - last - 1);
                last = j;
            }
        if (last + 1 != m)
            ansg = min(ansg, m - last - 1);
    }

    for (j = 0; j < m; j++)
    {
        int last = -1;
        for (i = 0; i < n; i++)
            if (a[i][j] == 0)
            {
                if (i != last + 1)
                    ansv = min(ansv, i - last - 1);
                last = i;
            }
        if (last + 1 != n)
            ansv = min(ansv, n - last - 1);
    }

    cout << ansv*ansg;
}

//#undef int

int main()
{
//    srand(time(0));
//    srand(8);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    ifstream cin("input.txt");
//    ofstream cout("output.txt");
//    ifstream cin("output.txt");
//    ifstream fin("12.out");
//    int a, b, i = 0;
//    while (cin >> a)
//    {
//        fin >> b;
//        if (a != b)
//        {
//            cout << i << " " << a << " " << b;
//            return 0;
//        }
//        i++;
//    }
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    freopen("f.in", "r", stdin);
//    freopen("f.out", "w", stdout);
//    int t = 10000;
//    while (t--)
//    {
//        if (t == 9947)
//            t = 9947;
//        gen();
//        cout << t << endl;
//        brut();
//        if (!solve())
//        {
//            cout << "kek";
//            return 0;
//        }
//    }
    solve();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...