답안 #338891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338891 2020-12-24T07:00:19 Z IZhO_2021_I_want_Silver 호화 벙커 (IZhO13_burrow) C++14
0 / 100
1 ms 364 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>-

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define show(a) cerr << #a <<" -> "<< a <<" "
#define nl cerr <<"\n"
//#define int ll

const int N = 1005;
const int oo = 1e9 + 5;

int n, m, k, a[N][N], h[N];
stack <int> st;

int check(int x) {
    for (int j = 1; j <= m; ++j) {  h[j] = 0; }
    while (sz(st)) { st.pop(); }

    int mx = 0;
    for (int i = 1; i <= n; ++i) {
        //st.push(0); h[0] = 0;
        for (int j = 1; j <= m; ++j) {
            if (a[i][j] >= x) { h[j] = h[j] + 1; }
            else { h[j] = 0; }

            while (sz(st) && h[st.top()] >= h[j]) { st.pop(); }
            if (sz(st)) {
                //show(i); show(st.top()); show(j); show(h[j]); nl;
                mx = max(mx, (j - st.top()) * h[j]);
            }
            st.push(j);
        }
        while (sz(st)) { st.pop(); }
    }
    if (mx >= k) { return mx; }
    return 0;
}

void solve() {
    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> a[i][j];
        }
    }
    int l = 1, r = oo;
    while (l < r) {
        int mid = (l + r + 1) / 2;
        if (check(mid)) l = mid;
        else r = mid - 1;
    }
    cout << l <<" "<< check(l) <<"\n";

}

 main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tests = 1;
	//cin >> tests;
	while (tests --) {
		solve();
	}
	return 0;
}
/*
    Just Chalish!
3 3 3
1 1 1
1 2 2
1 2 2
*/

Compilation message

burrow.cpp:85:8: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   85 |  main () {
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -