# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
315680 | Trickster | 호화 벙커 (IZhO13_burrow) | C++14 | 1347 ms | 26876 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#define N 1010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mod 1000000007
#define pii pair <int, int>
using namespace std;
int n, m, k;
int v[N][N];
int H[N][N];
pii p[N][N];
int main()
{
cin >> n >> m >> k;
for(int i = 1; i <= n; i++)
for(int h = 1; h <= m; h++)
cin >> v[i][h];
int l = 1, md, r = 1e9, ans, sz;
while(l <= r) {
md = (l+r)/2;
char c[N][N];
for(int i = 1; i <= n; i++)
for(int h = 1; h <= m; h++) {
c[i][h] = '0';
if(v[i][h] >= md) c[i][h] = '1';
}
for(int i = n; i >= 1; i--) {
memset(H[i], 0, sizeof(H[i]));
for(int h = 1; h <= m; h++) if(c[i][h] == '1') H[i][h] = H[i+1][h] + 1;
}
for(int i = 1; i <= n; i++) {
vector <int> E;
for(int h = 1; h <= m; h++) {
p[i][h] = {0, m};
while(!E.empty() && H[i][E.back()] > H[i][h]) {
p[i][E.back()].ss = h-1;
E.pop_back();
}
if(E.empty()) p[i][h].ff = 1;
else {
if(H[i][E.back()] == H[i][h]) p[i][h].ff = p[i][E.back()].ff;
else p[i][h].ff = E.back()+1;
}
E.pb(h);
}
}
int now = 0;
for(int i = 1; i <= n; i++)
for(int h = 1; h <= m; h++)
now = max(now, H[i][h] * (p[i][h].ss - p[i][h].ff + 1));
if(now >= k) {
ans = md, sz = now;
l = md+1;
} else r = md-1;
}
cout << ans << " " << sz;
}
/*
3 3 3
1 1 1
1 2 2
1 2 2
1 10 5
4 3 2 5 10 7 6 5 1 100
3 5 2
5 7 5 5 5
8 5 5 7 5
8 5 8 8 8
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |