제출 #47579

#제출 시각아이디문제언어결과실행 시간메모리
47579dqhungdlLuxury burrow (IZhO13_burrow)C++17
100 / 100
569 ms4732 KiB
#include <bits/stdc++.h>
using namespace std;

int m,n,k,L[1005],R[1005],h[1005],a[1005][1005];

int Check(int lim)
{
	for(int i=1;i<=n;i++)
		h[i]=0;
	int maxn=0;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
			if(a[i][j]>=lim)
				h[j]++;
			else
				h[j]=0;
		for(int j=1;j<=n;j++)
	    {
	    	L[j]=j;
	        int tmp=j-1;
	        while(tmp>0&&h[j]<=h[tmp])
	        {
	            L[j]=L[tmp];
	            tmp=L[tmp]-1;
	        }
	    }
	    for(int j=n;j>=1;j--)
	    {
	        R[j]=j;
	        int tmp=j+1;
	        while(tmp<=n&&h[j]<=h[tmp])
	        {
	            R[j]=R[tmp];
	            tmp=R[tmp]+1;
	        }
	    }
	    for(int j=1;j<=n;j++)
	    	maxn=max(maxn,h[j]*(R[j]-L[j]+1));		   
	}
	return maxn;
}

int main()
{
	ios_base::sync_with_stdio(false);
	//freopen("TEST.INP","r",stdin);
	//freopen("TEST.OUT","w",stdout);
	cin>>m>>n>>k;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	int area,rs,l=1,r=1e9;
	while(l<=r)
	{
		int mid=(l+r)/2;
		int tmp=Check(mid);
		if(tmp>=k)
		{
			area=tmp;
			rs=mid;
			l=mid+1;
		}
		else
			r=mid-1;
	}
	cout<<rs<<' '<<area;
}

컴파일 시 표준 에러 (stderr) 메시지

burrow.cpp: In function 'int main()':
burrow.cpp:67:12: warning: 'rs' may be used uninitialized in this function [-Wmaybe-uninitialized]
  cout<<rs<<' '<<area;
            ^~~
burrow.cpp:67:15: warning: 'area' may be used uninitialized in this function [-Wmaybe-uninitialized]
  cout<<rs<<' '<<area;
  ~~~~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...