Submission #42306

# Submission time Handle Problem Language Result Execution time Memory
42306 2018-02-25T22:01:27 Z wilwxk Luxury burrow (IZhO13_burrow) C++14
100 / 100
695 ms 54624 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN=1e3+3;
int ori[MAXN][MAXN];
int h[MAXN][MAXN];
int ent[MAXN];
stack<int> st, sti;
int xx, yy, x, respf, maior;

int testa(int k) {
    for(int i=1; i<=xx; i++) {
        for(int j=1; j<=yy; j++) {
            if(ori[i][j]>=k) h[i][j]=1; else h[i][j]=0;
            if(h[i][j]==1) h[i][j]=h[i-1][j]+1; else h[i][j]=0;
        }
    }
    int resp=0;
    for(int i=1; i<=xx; i++) {
        while(st.size()) { st.pop(); sti.pop(); } ent[0]=0; st.push(-2); sti.push(0);
        for(int j=1; j<=yy+1; j++) {
            int cur=h[i][j]; if(j==yy+1) cur=-1;
            while(st.top()>=cur) {
                int area=st.top()*(j-ent[sti.top()]);
                resp=max(resp, area);
                st.pop(); sti.pop();
            }
            ent[j]=sti.top(); ent[j]++;
            st.push(h[i][j]); sti.push(j);
        }
    }
    //printf("%d : %d\n", k, resp);
    if(resp>=x) return resp;
    else return -1;

}

int main() {

    scanf("%d %d %d", &xx, &yy, &x);
    for(int i=1; i<=xx; i++) {
        for(int j=1; j<=yy; j++) {
            scanf("%d", &ori[i][j]); maior=max(maior, ori[i][j]);
        }
    }

    respf=0;
    for(int i=maior; i>=1; i/=2) {
        while(testa(respf+i)!=-1) respf+=i;
    }

    printf("%d %d\n", respf, testa(respf));


}

Compilation message

burrow.cpp: In function 'int main()':
burrow.cpp:40:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &xx, &yy, &x);
                                    ^
burrow.cpp:43:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &ori[i][j]); maior=max(maior, ori[i][j]);
                                    ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Correct 2 ms 788 KB Output is correct
5 Correct 2 ms 896 KB Output is correct
6 Correct 2 ms 936 KB Output is correct
7 Correct 2 ms 936 KB Output is correct
8 Correct 5 ms 1492 KB Output is correct
9 Correct 11 ms 2420 KB Output is correct
10 Correct 50 ms 2684 KB Output is correct
11 Correct 53 ms 3796 KB Output is correct
12 Correct 18 ms 5776 KB Output is correct
13 Correct 48 ms 5776 KB Output is correct
14 Correct 49 ms 6152 KB Output is correct
15 Correct 56 ms 6832 KB Output is correct
16 Correct 88 ms 7832 KB Output is correct
17 Correct 45 ms 9156 KB Output is correct
18 Correct 236 ms 12688 KB Output is correct
19 Correct 182 ms 15280 KB Output is correct
20 Correct 603 ms 21620 KB Output is correct
21 Correct 487 ms 28900 KB Output is correct
22 Correct 665 ms 39168 KB Output is correct
23 Correct 695 ms 48772 KB Output is correct
24 Correct 254 ms 51376 KB Output is correct
25 Correct 281 ms 54624 KB Output is correct