5个WA 看不到评测点 求助
查看原帖
5个WA 看不到评测点 求助
576690
ztyx楼主2024/4/22 18:49
#include <bits/stdc++.h>
using namespace std;

struct node
{
	int x,y,h;
};

vector<node> v;

bool cmp(node x,node y)
{
	return x.h<y.h;
}

int dp[105][105],H[105][105];

int dx[5]={0,1,-1,0,0};
int dy[5]={0,0,0,1,-1};

int main()
{
	int r,c;
	cin >> r >> c;
	for(int i=1;i<=r;i++)
	for(int j=1;j<=c;j++)
	{
		node NEW;
		NEW.x=i;
		NEW.y=j;
		cin >> H[i][j];
		NEW.h=H[i][j];
		v.push_back(NEW);
	}
	
	sort(v.begin(),v.end(),cmp);
	
	for(int j=0;j<v.size();j++)
	{
		for(int i=1;i<=4;i++)
		{
			if(H[v[j].x][v[j].y]>H[v[j].x+dx[i]][v[j].y+dy[i]])
			{
				dp[v[j].x][v[j].y]=max(dp[v[j].x][v[j].y],dp[v[j].x+dx[i]][v[j].y+dy[i]]+1);
			}
			
		}
	}
	
	int maxn=0;
	
	for(int i=1;i<=r;i++)
	for(int j=1;j<=c;j++)
	{
		maxn=max(maxn,dp[i][j]);
	}
	
	
	cout << maxn;

	return 0;
}
2024/4/22 18:49
加载中...