收获:
1.看清题意,求最长长度
2.>表示小顶堆,默认大顶堆
3./如果用const则参数列表为一个参数:则一般使用friend
代码:
1.优先队列+dp
#include<iostream>
#include<queue>
using namespace std;
struct node
{
int i,j,num;
friend bool operator <(const node &x,const node &y) //如果用const则参数列表为一个参数
{
return x.num>y.num; //>表示小顶堆
}
};//结构体存点
//struct cmp1{
// bool operator()(node x,node y){
// return x.num>y.num;
// }
//};//优先队列小的在前面
//priority_queue<node,vector<node>,cmp1>q;//stl大法好
priority_queue<node>q;
int n,m,maxn,maxj,maxi,w,top=0,g[105][105],f[105][105];
int main()
{
cin>>n>>m;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
f[i][j]=1;//长度最开始为1,它自己
cin>>g[i][j];
node a;
a.i=i;