shenmingxuan @ 2023-04-15 22:00:03
这个代码连exe文件都编译不了,请问有没有路过的大佬顺手调一下?
#include <bits/stdc++.h>
using namespace std;
const int MAXLEN = 100000;
int c[MAXLEN+1][MAXLEN+1];
int x[100005],y[100005];
int main(){
//freopen(“lcs.in”, “r”, stdin);
//freopen(“lcs.out”, “w”, stdout);
int n;
cin >> n;
for(int i = 0;i < n;i++){
cin >> x[i];
}
for(int i = 0;i < n;i++){
cin >> y[i];
}
memset(c, 0, sizeof(c));
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
if (x[i] == y[j]){
c[i][j] = c[i-1][j-1] + 1;
}
else{
if (c[i-1][j] > c[i][j-1]){
c[i][j] = c[i-1][j];
}
else{
c[i][j] = c[i][j-1];
}
}
}
}
cout << c[n-1][n-1] << endl;
return 0;
}
by shenmingxuan @ 2023-04-15 22:01:40
IDE显示的错误信息:
No valid executable file was produced by the compiler
./ccVdrMMV.o: in function `__static_initialization_and_destruction_0(int, int)':
src:(.text+0x2a1): relocation truncated to fit: R_X86_64_PC32 against `.bss'
src:(.text+0x2ba): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: 错误:ld 返回 1
by Sprague_Garundy @ 2023-04-15 22:03:56
@shenmingxuan 数组太大了。建议学学如何优化。
by shenmingxuan @ 2023-04-16 21:19:44
@Sprague_Garundy 谢谢