답안 #340463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340463 2020-12-27T16:12:35 Z beksultan04 호화 벙커 (IZhO13_burrow) C++14
100 / 100
1161 ms 33560 KB
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
const int N = 1e5+12,INF=1e9+7;
int q[2001][2001],l[2001][2001],a[2001][2001],n,m;
int le[N],re[N];
int fun(){
    int ans=0,i,j;
    for (i=1;i<=n;++i){
        for (j=1;j<=m;++j){
            if (q[i][j] == 1){
                l[i][j] = l[i-1][j]+1;
            }
            else
                l[i][j]=0;
        }
    }
    for (i=1;i<=n;++i){
        vector <pii> v;
        v.pb({0,0});
        for (j=1;j<=m;++j){
            if (l[i][j] == 0){
                v.clear();
                v.pb({0,j});
            }
            else {
                while (!v.empty() && l[i][j] <= v.back().fr)
                    v.pop_back();
                le[j]=v.back().sc;
                v.pb({l[i][j],j});
            }
        }v.clear();
        v.pb({0,m+1});
        for (j=m;j>=1;j--){
            if (l[i][j] == 0){
                v.clear();
                v.pb({0,j});
            }
            else {
                while (!v.empty() && l[i][j] <= v.back().fr)
                    v.pop_back();
                re[j]=v.back().sc;
                v.pb({l[i][j],j});
            }
        }
        for(j=1;j<=m;j++)
            ans=max(ans,(re[j]-le[j]-1)*l[i][j]);
    }
    ret ans;
}

void full(int x){
    int i,j;
    for (i=1;i<=n;++i){
        for (j=1;j<=m;++j){
            if (a[i][j] >= x){
                q[i][j]=1;
            }
            else q[i][j]=0;
            l[i][j]=0;
        }
    }
}

main(){
    int i,j,k;
    scan3(n,m,k)

    for (i=1;i<=n;++i){
        for (j=1;j<=m;++j){
            scan1(a[i][j])
        }
    }
    int l=1,r=INF;
    while (r-l>1){
        int m = l+r>>1;
        full(m);
        int x = fun();
        if (x >= k){
            l=m;
        }
        else {
            r=m;
        }
    }
    full(r);
    int x = fun();
    if (x >= k)l=r;
    full(l);
    x = fun();
    cout <<l<<" "<<x;

}






Compilation message

burrow.cpp:81:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   81 | main(){
      |      ^
burrow.cpp: In function 'int main()':
burrow.cpp:92:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   92 |         int m = l+r>>1;
      |                 ~^~
burrow.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 | #define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~
burrow.cpp:83:5: note: in expansion of macro 'scan3'
   83 |     scan3(n,m,k)
      |     ^~~~~
burrow.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 | #define scan1(a) scanf("%d",&a);
      |                  ~~~~~^~~~~~~~~
burrow.cpp:87:13: note: in expansion of macro 'scan1'
   87 |             scan1(a[i][j])
      |             ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 620 KB Output is correct
5 Correct 2 ms 748 KB Output is correct
6 Correct 2 ms 876 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 13 ms 1788 KB Output is correct
9 Correct 22 ms 3072 KB Output is correct
10 Correct 43 ms 3564 KB Output is correct
11 Correct 81 ms 4716 KB Output is correct
12 Correct 58 ms 7148 KB Output is correct
13 Correct 53 ms 2540 KB Output is correct
14 Correct 169 ms 7708 KB Output is correct
15 Correct 172 ms 7788 KB Output is correct
16 Correct 179 ms 8192 KB Output is correct
17 Correct 233 ms 9856 KB Output is correct
18 Correct 433 ms 14572 KB Output is correct
19 Correct 531 ms 16492 KB Output is correct
20 Correct 843 ms 23096 KB Output is correct
21 Correct 908 ms 26988 KB Output is correct
22 Correct 1161 ms 33560 KB Output is correct
23 Correct 1159 ms 33388 KB Output is correct
24 Correct 778 ms 23532 KB Output is correct
25 Correct 942 ms 26792 KB Output is correct