Checker Finished.
查看原帖
Checker Finished.
60864
tiger2005楼主2021/4/25 17:50
#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

inline bool checkContain(string t,string s){
	int N=s.size(),M=t.size();
	vector<int> vec(N);
	vec[0]=-1;int j=-1;
	for(int i=1;i<N;i++){
		while(j!=-1 && s[i]!=s[j+1])	j=vec[j];
		if(s[i]==s[j+1])	++j;
		vec[i]=j;
	}
	j=-1;
	for(int i=0;i<M;i++){
		while(j!=-1 && s[j+1]!=t[i])	j=vec[j];
		if(s[j+1]==t[i])	++j;
		if(j==N-1)	return true;
	}
	return false;
}
inline bool checkSmallCase(string t){
	for(int i=0;i<(int)t.size();i++)
		if(t[i]<'a' || t[i]>'z')	return false;
	return true;
}
int main(int argc, char** argv){
	registerTestlibCmd(argc,argv);
	string E, S, T, A;
	E = inf.readLine();
	S = inf.readLine();
	T = ouf.readLine();
	A = ans.readLine();
	if(T.size() != A.size())
		quitf(_wa, "Wrong Answer!");
	if(T == "NO" && A == "NO")
		quitf(_ok, "Answer Correct!");
	regex e("^"+E+"$", regex_constants::grep);
	if(checkSmallCase(T) && regex_match(T, e) && checkContain(T, S))
		quitf(_ok, "Answer Correct!");
	quitf(_wa, "Wrong Answer!");
}
2021/4/25 17:50
加载中...