开始 2023-11-25 00:00:00

1125练习

结束 2023-12-02 00:00:00
Contest is over.
当前 2024-12-22 20:41:13

问个问题,T5有SPJ吗

我是从这题拿的代码,这题我出的,std绝对没有问题,但放上来就只对了4个点,我怀疑这题没有SPJ。所以如果没有SPJ请添加,因为一个序列中可能不止一个最长不下降子序列,比如序列 1,2,1,2 就有2个最长不下降子序列。

我从洛谷那题的SPJ改了一点点的SPJ代码:

#include "testlib.h"
using namespace std;
int main(int argc, char* argv[]){
    registerTestlibCmd(argc, argv);
    string nn = ouf.readString();
    string ansn = ans.readString();
    if (nn != ansn){
    	quitf(_wa,"Your answer's length is wrong.");
	}
	int n = 0;
	for (int i = nn.size() - 1;i >= 4;i--){
		n = n * 10 + nn[i] - '0';
	}
	int a[114514],b[114514];
	for (int i = 1;i <= n;i++){
		a[i] = inf.readInt();
	}
	for (int i = 1;i <= l;i++){
		b[i] = ouf.readInt();
	}
	for (int i = 2;i <= l;i++){
		if (!(b[i - 1] <= b[i])){
			quitf(_wa,"Your answer is wrong.");
		}
	}
	int o = 1,sum = 0;
	for (int i = 1;i <= l;i++){
		int j = 0;
		for (j = o;j <= n;j++){
			if (a[j] == b[i]){
				sum++;
				break;
			}
		}
		o = j;
	}
	if (sum == ansl){
		quitf(_ok,"Your answer is correct.");
	}
	else{
		quitf(_wa,"Your answer is wrong.");
	}
}

chenzhixuan  •  1年前

比赛已结束。