一道求最长递增公共子序列的题,本地编译不成
题目描述:求两个整形序列的最长公共递增子序列,只需要输出其长度。其中两序列长度1<=n,m<=100000,每个元素大小在[1,1000000]之间,测试样例不多于1000组。代码:
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int s1[100010],s2[100010],max_Length[100010][100010],s[100010],maxLen[100010];
int max_L(int *s,int k){ //求一维数组最大元素的下标
int i=0,m=0;
while(i<k){
if(s[i]>s[m]) m=i;
i++;
}
return m;
}
int main(void){
int T,n,m,i,j,k;
cin>>T;
while(T--){ //先求出最长公共子序列,再求其中递增元素的个数
cin>>n>>m;
for(i=0;i<n;i++) cin>>s1[i];
for(j=0;j<m;j++) cin>>s2[i];
for(i=0;i<=n;i++) max_Length[i][0]=0;
for(j=0;j<=m;j++) max_Length[0][j]=0;
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
if(s1[i-1]==s2[j-1]) max_Length[i][j]=max_Length[i-1][j-1]+1;
else max_Length[i][j]=max(max_Length[i-1][j],max_Length[i][j-1]);
}
} //模板题,求出最长公共子序列元素个数
for(i=0,j=1;j<=m;j++){
if(max_Length[n][j]>max_Length[n][j-1]) s[i++]=s2[j-1]; //求出最长公共子序列,存到数组s里面
}
k=i;
for(i=0;i<k;i++) maxLen[i]=1; //模板题,求出最长递增子序列的元素个数
for(i=1;i<k;i++){
for(j=0;j<i;j++){
if(maxLen[i]>maxLen[j]) maxLen[i]=max(maxLen[i],maxLen[j]+1);
}
}
cout<<max_L(maxLen,k);
}
return 0;
}
编译的时候显示:
C:\Users\Lenovo\AppData\Local\Temp\ccA7g89Q.s Assembler messages:
278 C:\Users\Lenovo\AppData\Local\Temp\ccA7g89Q.s Error: value of 0000000950b5dcb2 too large for field of 4 bytes at 0000000000000372
294 C:\Users\Lenovo\AppData\Local\Temp\ccA7g89Q.s Error: value of 0000000950bbf7a8 too large for field of 4 bytes at 00000000000003a8
310 C:\Users\Lenovo\AppData\Local\Temp\ccA7g89Q.s Error: value of 0000000950bbf7e7 too large for field of 4 bytes at 00000000000003e7
315 C:\Users\Lenovo\AppData\Local\Temp\ccA7g89Q.s Error: value of 0000000950bbf7fe too large for field of 4 bytes at 00000000000003fe
322 C:\Users\Lenovo\AppData\Local\Temp\ccA7g89Q.s Error: value of 0000000950bbf819 too large for field of 4 bytes at 0000000000000419
求帮忙看下怎么回事?