# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
833173 | vjudge1 | Bomb (IZhO17_bomb) | C++17 | 96 ms | 27504 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;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const int MOD = 1000000007;
const int dx[] = {0, 0, 1, -1, 1, -1, -1, 1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define pob pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define lsort(x) sort(all(x))
#define gsort(x) sort(all(x), greater<>())
#define rev(x) reverse(all(x))
#define mset(x, y) memset(x, y, sizeof(x))
#define vin(x, y) for(int i = 0; i < y; i++){decltype(x)::value_type temp; cin >> temp; x.pb(temp);}
#define vout(x) for(auto i : x){cout << i << " ";} cout << endl;
#define decide(x) if(x){ cout << "YES" << endl; }else{ cout << "NO" << endl; }
#define test(x) cout << "..." << endl
template<typename T> void chmin(T& x, T y) {if(x > y) x = y;}
template<typename T> void chmax(T& x, T y) {if(x < y) x = y;}
void fastIO(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, m;
int arr[2500][2500];
void solve(){
//IO
cin >> n >> m;
for(int i = 0; i < n; i++){
string temp;
cin >> temp;
for(int j = 0; j < m; j++) arr[i][j] = temp[j] - '0';
}
ll w = LLONG_MAX;
ll l = LLONG_MAX;
for(int i = 0; i < n; i++){
ll curr = 0;
for(int j = 0; j < m; j++){
if(arr[i][j] == 1) curr++;
else{
if(curr > 0) chmin(w, curr);
curr = 0;
}
}
if(curr > 0) chmin(w, curr);
}
for(int i = 0; i < m; i++){
ll curr = 0;
for(int j = 0; j < n; j++){
if(arr[j][i] == 1) curr++;
else{
if(curr > 0) chmin(l, curr);
curr = 0;
}
}
if(curr > 0) chmin(l, curr);
}
// cout << w << " " << l << endl;
cout << w * l << endl;
}
int main(){
fastIO();
int t = 1;
// cin >> t;
while(t--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |