# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
832239 | vjudge1 | Bomb (IZhO17_bomb) | C++14 | 1094 ms | 56744 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define ll long long
#define rep(i,n,N) for(int i = n; i<=N; ++i)
#define rap(i,n,N) for(int i = n; i>=N; --i)
#define For(i,n,N) for(int i = n; i< N; ++i)
#define endl '\n'
#define pb push_back
#define all(x) x.begin(),x.end()
#define mems(x,y) memset(x,y,sizeof x)
#define ari(x) array<int,x>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first
#define se second
const int MAX = 2500 + 5;
mt19937 rng(time(NULL));
int n,m,mnr,mnc,cnt,y[MAX][MAX],z[MAX][MAX];
char c;
bool x[MAX][MAX];
vector<ari(3)> v;
inline bool cek(int r,int c,int dr,int dc){
return y[r][c] - y[r-dr][c] - y[r][c-dc] + y[r-dr][c-dc] == dr*dc;
}
inline void solve(int dr,int dc){
mems(z, 0);
rep(i,dr,n)rep(j,dc,m)if(x[i][j] && cek(i,j,dr,dc)){
z[i][j]++;
z[i-dr][j]--;
z[i][j-dc]--;
z[i-dr][j-dc]++;
}
rap(i,n,1)rap(j,m,1){
z[i][j]+= z[i+1][j]+z[i][j+1]-z[i+1][j+1];
if((!!z[i][j])!=x[i][j])return;
}
cout<<dr*dc<<endl;
exit(0);
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n>>m;
mnr = n, mnc = m;
rep(i,1,n){
rep(j,1,m){
cin>>c;
x[i][j] = c=='1';
y[i][j] = y[i-1][j]+y[i][j-1]-y[i-1][j-1]+x[i][j];
if(x[i][j])++cnt;
else if(cnt)mnc = min(mnc, cnt), cnt = 0;
}
if(cnt)mnc = min(mnc, cnt), cnt = 0;
}
rep(j,1,m){
rep(i,1,n){
if(x[i][j])++cnt;
else if(cnt)mnr = min(mnr, cnt), cnt = 0;
}
if(cnt)mnr = min(mnr, cnt), cnt = 0;
}
solve(mnr, mnc);
int ar = max(1, mnr-100);
int ac = max(1, mnc-100);
rep(i,ar,mnr)rep(j,ac,mnc)v.pb({i*j, i, j});
v.pop_back();
sort(all(v));
reverse(all(v));
for(auto &i:v)solve(i[1], i[2]), cout<<i[1]<<" "<<i[2]<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |