题目链接:https://vjudge.net/problem/UVA-111
解题思路:
题目意思大概是输入n,下一行输出n个数
然后接下去多组输出,每组输入n个数(1~n)
然后按照第一行那n个数排序,然后求排序后的最长上升子序列
代码中重要变量的意思:
int ord【22】---> 储存第一行,每次都赋值给结构体中的order,用于排序。
下面是代码:(虽然明知道可以用ologn的LIS,代码还是写了LCS)
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int ord[22];
int dp[22][22];
struct node
{
int a;
int order;
bool operator < (const node &a)const{
return this->order<a.order;
}
}b[22];
int main()
{
int n;
scanf("%d",&n);
for (int i=1;i<=n;i++) scanf("%d",&ord[i]);
while (~scanf("%d",&b[1].a)){
b[1