下方代码在VS,DEV,洛谷IDE中得到相同结果,但测评WA40分 https://www.luogu.com.cn/record/128871177
// P1481.cpp : 魔族密码
#include <iostream>
using namespace std;
int N;
int Wsize[2005];
int DP[2005];
char W[2005][79];
bool TF(char a) {
return (a == '\n' or a == EOF) ? 0 : 1;
}
bool Has(int A, int B) {
for (int i = 0; i < Wsize[A]; i++) {
if (W[A][i] != W[B][i])return false;
}
return true;
}
int main()
{
cin >> N; getchar();
for (int i = 0; i < N; i++) {
while (TF(W[i][Wsize[i]++] = getchar()));
Wsize[i]--;
}
DP[0] = 1;
int MAX = 0;
for (int i = 1; i < N; i++) {
DP[i] = 0;
for (int j = 0; j < i; j++) {
if (Has(j, i) && DP[i] < DP[j]) {
DP[i] = DP[j];
}
}
DP[i]++;
if (DP[i] > MAX) MAX = DP[i];
}
cout << MAX;
return 0;
}
对于测试点2,其测试数据为 https://www.luogu.com.cn/paste/tyewmuvp
在VS,DEV中运行结果均为正解75,在洛谷IDE上由于输入太大,简化后输出仍为75,但提交WA,提示第一个字符输出2
至少在我自己来看,应该没什么炸内存或者初始化的毛病,不知道怎么就这样了,求大佬调