# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
108946 | ihdignite | Bomb (IZhO17_bomb) | C++14 | 1096 ms | 132096 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mxN=2500;
int n, m, mc=mxN, ans, p[mxN*mxN], s[mxN*mxN];
string g[mxN];
vector<array<int, 2>> ta[mxN+1];
priority_queue<int, vector<int>, greater<int>> pq1, pq2;
int find(int x) {
return x==p[x]?x:(p[x]=find(p[x]));
}
void join(int x, int y) {
if((x=find(x))==(y=find(y)))
return;
if(s[x]<s[y])
swap(x, y);
p[y]=x;
pq2.push(s[x]);
pq2.push(s[y]);
s[x]+=s[y];
pq1.push(s[x]);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i=0; i<n; ++i) {
cin >> g[i];
for(int j=0, l=0; j<m; ++j) {
l=g[i][j]&1?1+l:0;
ta[l].push_back({i, j});
if(l&&(j+1>=m||g[i][j+1]&1^1))
mc=min(l, mc);
}
}
iota(p, p+n*m, 0);
for(int i=n; i; --i) {
for(array<int, 2> a : ta[i]) {
pq1.push(s[a[0]*m+a[1]]=1);
if(a[0]&&s[a[0]*m-m+a[1]])
join(a[0]*m+a[1], a[0]*m-m+a[1]);
if(a[0]<n-1&&s[a[0]*m+m+a[1]])
join(a[0]*m+a[1], a[0]*m+m+a[1]);
}
while(pq1.size()&&pq2.size()&&pq1.top()==pq2.top()) {
pq1.pop();
pq2.pop();
}
if(i<=mc)
ans=max(i*pq1.top(), ans);
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |