样例过了,但是10分,求助!
查看原帖
样例过了,但是10分,求助!
1034242
RingTouSou楼主2023/12/13 16:47
// Problem: 
//     P2285 [HNOI2004] 打鼹鼠
//   
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P2285
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=1005;
int f1[N][N];  //存储放变化 
int f2[N][N];  //结果
int n,m;
int ans;
bool check=true;


int main(){
	cin>>n>>m;
	int pre;
	int now;
	int x,y;
	while(n--){
		cin>>now;
		if(check) pre=now,check=false;
		if(now!=pre) memcpy(f1, f2, sizeof f2);
		cin>>x>>y;
		f2[x][y]=max(max(f1[x-1][y],f1[x][y-1]),max(f1[x+1][y],f1[x][y+1]))+1;
		pre=now;
		ans=max(ans,f2[x][y]);
	}
	cout<<ans<<endl;
	return 0;
}
2023/12/13 16:47
加载中...