# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
831245 | vjudge1 | Bomb (IZhO17_bomb) | C++17 | 87 ms | 6528 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//turn on extra precision
//#pragma GCC target("fpmath=387")
using namespace std;
using namespace __gnu_pbds;
using str = string;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector <pll>;
template<class A, class B>
ostream& operator<<(ostream& os, const pair<A, B> &p) {
os << '(' << p.first << ',' << p.second << ')';
return os;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T> &v) {
bool van = 1; os << '{';
for(auto &i : v) { if(!van) os << ", "; os << i; van = 0; }
os << '}'; return os;
}
template<class T, size_t sz>
ostream& operator<<(ostream&os, const array<T,sz> &arr) {
bool fs = 1; os << '{';
for(auto &i : arr) { if(!fs) os << ", "; os << i; fs = 0; }
os << '}'; return os;
}
#define mp make_pair
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define all(x) x.begin(), x.end()
#define watch(x) cerr << (#x) << " is : " << (x) << newl
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T>
ll quickpow(ll num1, ll num2, const T MOD) {
assert(num2 >= 0); ll ans = 1;
for(; num2; num2>>=1, num1 = num1 * num1 % MOD) if(num2 & 1) ans = ans * num1 % MOD;
return ans;
}
// end of Template
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<vector<char>> g(n, vector<char>(m));
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) {
cin >> g[i][j];
}
}
int ro = -1, co = -1;
for(int i = 0; i < n; ++i) {
int len = 0, mn = 1e9;
for(int j = 0; j < m; ++j) {
if(g[i][j] == '1') ++len;
else {
if(len) mn = min(mn, len);
len = 0;
}
}
if(len) mn = min(mn, len);
if(mn == 1e9) continue;
ro = (ro == -1 ? mn : min(ro, mn));
}
for(int j = 0; j < m; ++j) {
int len = 0, mn = 1e9;
for(int i = 0; i < n; ++i) {
if(g[i][j] == '1') ++len;
else {
if(len) mn = min(mn, len);
len = 0;
}
}
if(len) mn = min(mn, len);
if(mn == 1e9) continue;
co = (co == -1 ? mn : min(co, mn));
}
if(ro == -1 || co == -1) return cout << 0 << newl, 0;
cout << ro * co << newl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |