답안 #47557

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47557 2018-05-05T03:41:16 Z JohnTitor 호화 벙커 (IZhO13_burrow) C++11
100 / 100
632 ms 12488 KB
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define setbit(s, i) (s|=(1LL<<(i)))
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "F"
int n, m, k;
int a[1001][1001];
int h[1001][1001];
int l[1001];
int r[1001];
vector <int> v;
int make(int c){
    FOR(i, 1, n) FOR(j, 1, m) if(a[i][j]>=c) h[i][j]=h[i-1][j]+1; else h[i][j]=0;
    int maxs=0;
    deque <int> d;
    FOR(i, 1, n){
        d.clear();
        FOR(j, 1, m){
            while((!d.empty())&&(h[i][j]<=h[i][d.back()])) d.pop_back();
            l[j]=(d.empty())?1:d.back()+1;
            d.pb(j);
        }
        d.clear();
        DFOR(j, m, 1){
            while((!d.empty())&&(h[i][j]<=h[i][d.back()])) d.pop_back();
            r[j]=(d.empty())?m:d.back()-1;
            d.pb(j);
        }
        FOR(j, 1, m) maxs=max(maxs, h[i][j]*(r[j]-l[j]+1));
    }
    return maxs;
}
int main(){
    #ifdef Kanikou
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Kanikou
    read(n);
    read(m);
    read(k);
    FOR(i, 1, n) FOR(j, 1, m){
        read(a[i][j]);
        v.pb(a[i][j]);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int low=0, high=v.size()-1, mid, ans, best, res;
    while(low<=high){
        mid=(low+high)/2;
        res=make(v[mid]);
        if(res>=k){
            ans=v[mid];
            best=res;
            low=mid+1;
        }
        else high=mid-1;
    }
    write(ans);
    putchar(' ');
    write(best);
}

Compilation message

burrow.cpp: In function 'int main()':
burrow.cpp:97:10: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
     write(best);
     ~~~~~^~~~~~
burrow.cpp:95:10: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
     write(ans);
     ~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 664 KB Output is correct
5 Correct 2 ms 676 KB Output is correct
6 Correct 2 ms 696 KB Output is correct
7 Correct 2 ms 696 KB Output is correct
8 Correct 5 ms 1472 KB Output is correct
9 Correct 9 ms 2172 KB Output is correct
10 Correct 24 ms 2260 KB Output is correct
11 Correct 40 ms 2772 KB Output is correct
12 Correct 21 ms 4692 KB Output is correct
13 Correct 30 ms 4692 KB Output is correct
14 Correct 57 ms 4692 KB Output is correct
15 Correct 67 ms 4692 KB Output is correct
16 Correct 88 ms 4692 KB Output is correct
17 Correct 43 ms 5584 KB Output is correct
18 Correct 220 ms 6820 KB Output is correct
19 Correct 210 ms 8164 KB Output is correct
20 Correct 511 ms 9380 KB Output is correct
21 Correct 477 ms 10916 KB Output is correct
22 Correct 616 ms 12452 KB Output is correct
23 Correct 632 ms 12452 KB Output is correct
24 Correct 322 ms 12452 KB Output is correct
25 Correct 241 ms 12488 KB Output is correct