# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
340440 | 2020-12-27T15:44:14 Z | beksultan04 | 호화 벙커 (IZhO13_burrow) | C++14 | 19 ms | 364 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 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; } } } for (i=1;i<=n;++i){ vector <pii> v; for (j=1;j<=m;++j){ if (l[i][j] == 0){ v.clear(); } else { int pos = j; while (!v.empty() && l[i][j] <= v.back().fr){ pos = v.back().sc; v.pop_back(); } if (!v.empty()){ ans = max(ans,(j-v.back().sc+1)*v.back().fr); } v.pb({l[i][j],pos}); ans = max(ans,(j-pos+1)*l[i][j]); } } } for (i=1;i<=n;++i){ vector <pii> v; for (j=m;j>0;--j){ if (l[i][j] == 0){ v.clear(); } else { int pos = j; while (!v.empty() && l[i][j] <= v.back().fr){ pos = v.back().sc; v.pop_back(); } if (!v.empty()){ ans = max(ans,(v.back().sc-j+1)*v.back().fr); } v.pb({l[i][j],pos}); ans = max(ans,(pos-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=100000,x; while (r--){ full(r); x = fun(); if (x >= k)break; } cout <<r<<" "<<x; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |