# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
89107 | 2018-12-10T10:11:50 Z | nika | 호화 벙커 (IZhO13_burrow) | C++14 | 1130 ms | 50644 KB |
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define lo long long #define inf 1000000000 #define md 1000000007 #define pb push_back #define li 1005 #define ii pair<int,int> using namespace std; int n,m,k,A[li][li],cur[li],ans,fa[li],sz[li]; vector<int> nxt[li]; int dsu(int x){ if(fa[x]==x) return x; return fa[x]=dsu(fa[x]); } void union1(int a,int b){ int s1=dsu(a); int s2=dsu(b); if(s1==s2) return ; if(sz[s1]<sz[s2]) swap(s1,s2); fa[s2]=s1; sz[s1]+=sz[s2]; sz[s2]=0; } void solve(int ind){ for(int i=0;i<=m;i++) nxt[i].clear(); for(int i=1;i<=n;i++){ nxt[cur[i]-ind].pb(i); } for(int i=1;i<=n;i++){ fa[i]=-1; sz[i]=1; } for(int i=m;i>=1;i--){ for(int j=0;j<(int)nxt[i].size();j++){ int go=nxt[i][j]; fa[go]=go; if(go>1 && fa[go-1]!=-1){ union1(go,go-1); } if(go<n && fa[go+1]!=-1){ union1(go,go+1); } ans=max(ans,i*sz[dsu(go)]); } } } int check(int x){ ans=0; for(int i=1;i<=n;i++) cur[i]=m+1; for(int i=m;i>=1;i--){ for(int j=1;j<=n;j++){ if(A[j][i]<x) cur[j]=i; } solve(i); } return ans; } int main(){ scanf("%d %d %d",&n,&m,&k); for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ scanf("%d",&A[i][j]); } } int bas=1,son=inf; while(bas<=son){ int mid=(bas+son)/2; if(check(mid)>=k) bas=mid+1; else son=mid-1; } printf("%d %d",son,check(son)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 500 KB | Output is correct |
4 | Correct | 3 ms | 616 KB | Output is correct |
5 | Correct | 3 ms | 856 KB | Output is correct |
6 | Correct | 3 ms | 856 KB | Output is correct |
7 | Correct | 5 ms | 856 KB | Output is correct |
8 | Correct | 8 ms | 1128 KB | Output is correct |
9 | Correct | 14 ms | 1944 KB | Output is correct |
10 | Correct | 27 ms | 2060 KB | Output is correct |
11 | Correct | 75 ms | 3064 KB | Output is correct |
12 | Correct | 30 ms | 4052 KB | Output is correct |
13 | Correct | 46 ms | 4052 KB | Output is correct |
14 | Correct | 97 ms | 5196 KB | Output is correct |
15 | Correct | 101 ms | 5388 KB | Output is correct |
16 | Correct | 128 ms | 7232 KB | Output is correct |
17 | Correct | 102 ms | 7232 KB | Output is correct |
18 | Correct | 414 ms | 11332 KB | Output is correct |
19 | Correct | 360 ms | 13028 KB | Output is correct |
20 | Correct | 829 ms | 19136 KB | Output is correct |
21 | Correct | 835 ms | 29008 KB | Output is correct |
22 | Correct | 1130 ms | 39356 KB | Output is correct |
23 | Correct | 1120 ms | 49172 KB | Output is correct |
24 | Correct | 522 ms | 49172 KB | Output is correct |
25 | Correct | 441 ms | 50644 KB | Output is correct |