QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#331767#7955. Tandem Copylzy2005TL 120ms83332kbC++145.5kb2024-02-18 19:10:242024-02-18 19:10:26

Judging History

你现在查看的是最新测评结果

  • [2024-02-18 19:10:26]
  • 评测
  • 测评结果:TL
  • 用时:120ms
  • 内存:83332kb
  • [2024-02-18 19:10:24]
  • 提交

answer

#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)

#include<bits/stdc++.h>

typedef unsigned ui;
typedef long long lli;
typedef unsigned long long ull;

const int F=(1<<30)-1;
const lli FF=(1ll<<62)-1ll;

namespace Fast_IO{
	const int SZ=1<<20;
	char buf[SZ+5],*p1,*p2;
	char obuf[SZ+5],*p3=obuf;
	char sbuf[45];int len=-1;
	inline char Get_Char(){
		if(p1==p2){
			p1=buf,p2=p1+fread(buf,1,SZ,stdin);
			if(p1==p2)return EOF;
		}
		return *p1++;
	}
	inline void Put_Char(char c){
		if(p3-obuf==SZ){
			fwrite(obuf,p3-obuf,1,stdout);
			p3=obuf;
		}
		*p3++=c;
	}
	inline int Get_Int(){
		int x=0;bool sg=0;
		char c=Get_Char();
		while(!isdigit(c)&&c!='-')c=Get_Char();
		if(c=='-')sg=1,c=Get_Char();
		while(isdigit(c))x=x*10+c-'0',c=Get_Char();
		return sg?-x:x;
	}
	inline lli Get_Int64(){
		lli x=0;bool sg=0;
		char c=Get_Char();
		while(!isdigit(c)&&c!='-')c=Get_Char();
		if(c=='-')sg=1,c=Get_Char();
		while(isdigit(c))x=x*10+c-'0',c=Get_Char();
		return sg?-x:x;
	}
	inline __int128_t Get_Int128(){
		__int128_t x=0;bool sg=0;
		char c=Get_Char();
		while(!isdigit(c)&&c!='-')c=Get_Char();
		if(c=='-')sg=1,c=Get_Char();
		while(isdigit(c))x=x*10+c-'0',c=Get_Char();
		return sg?-x:x;
	}
	inline void Put_Int(int x){
		if(x<0)Put_Char('-'),x=-x;
		len=-1;
		do buf[++len]=x%10+48,x/=10;while(x);
		while(len>=0)Put_Char(buf[len--]);
		Put_Char('\n');
	}
	inline void Put_Int64(lli x){
		if(x<0)Put_Char('-'),x=-x;
		len=-1;
		do buf[++len]=x%10+48,x/=10;while(x);
		while(len>=0)Put_Char(buf[len--]);
		Put_Char('\n');
	}
	inline void Put_Int128(__int128_t x){
		if(x<0)Put_Char('-'),x=-x;
		len=-1;
		do buf[++len]=x%10+48,x/=10;while(x);
		while(len>=0)Put_Char(buf[len--]);
		Put_Char('\n');
	}
	inline void Flush(){
		fwrite(obuf,p3-obuf,1,stdout);
	}
}
using Fast_IO::Get_Int;
using Fast_IO::Get_Int64;
using Fast_IO::Get_Int128;
using Fast_IO::Put_Int;
using Fast_IO::Put_Int64;
using Fast_IO::Put_Int128;
using Fast_IO::Flush;

const int N=2e4,AB=26;

char s[N+5],t[N+5];
int n,m;

int nx[N+5][AB+5],pr[N+5][AB+5],nx2[N+5][AB+5][AB+5];

struct Data{
	int w,x;
}da[AB+5];

int fw[N+5];
int ans;

int main(){
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1),m=strlen(t+1);

	std::fill(nx[m+1],nx[m+1]+AB,m+1);
	for(int i=m;i>=0;--i){
		std::copy(nx[i+1],nx[i+1]+AB,nx[i]);
		if(i)
			nx[i][t[i]-'A']=i;
		else
			for(int j=0;j<AB;++j)
				nx[i][j]=0;
	}

	std::fill(pr[0],pr[0]+AB,0);
	for(int i=1;i<=m+1;++i){
		std::copy(pr[i-1],pr[i-1]+AB,pr[i]);
		if(i!=m+1)
			pr[i][t[i]-'A']=i;
		else
			for(int j=0;j<AB;++j)
				pr[i][j]=m+1;
	}
	std::copy(pr[m+1],pr[m+1]+AB,pr[m+2]);

	for(int i=1;i<=m;++i){
		for(int j=0;j<AB;++j)
			da[j].w=j,da[j].x=nx[i][j];
		std::sort(da,da+AB,[](const Data&a,const Data&b){
			return a.x<b.x;
		});
		for(int j=0;j<AB;++j)
			for(int k=0;k<AB;++k){
				if(da[0].w!=j&&da[0].w!=k)
					nx2[i][j][k]=da[0].x;
				else if(da[1].w!=j&&da[1].w!=k)
					nx2[i][j][k]=da[1].x;
				else
					nx2[i][j][k]=da[2].x;
				if(nx2[i][j][k]==m+1)++nx2[i][j][k];
			}
	}

	for(int i=1;i<=n;++i){
		fw[i]=n+1;
		
		int l=0,r=nx2[1][s[i]-'A'][s[i]-'A']-1;
		if(r==m+1){
			fw[i]=i;
			continue;
		}

		for(int j=i+1;j<=n;++j){
			if(j!=i+1&&s[j]==s[j-2])
				l=nx[l][s[j]-'A'],r=pr[nx2[r+1][s[j]-'A'][s[j-1]-'A']][s[j]-'A'];
			else
				l=nx[r+1][s[j]-'A'],r=pr[nx2[r+1][s[j]-'A'][s[j-1]-'A']][s[j]-'A'];
			if(l>r)break;
			if(r==m+1){
				fw[i]=j;
				break;
			}
		}
	}

	for(int i=1;i<=n;++i)
		for(int j=i,mn=n+1;j<=n;++j){
			mn=std::min(mn,fw[j]);
			ans+=mn<=j;
		}
	
	printf("%d\n",ans);

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 10036kb

input:

ACGCG
CCG

output:

9

result:

ok single line: '9'

Test #2:

score: 0
Accepted
time: 1ms
memory: 10100kb

input:

TATCGC
TTCCG

output:

6

result:

ok single line: '6'

Test #3:

score: 0
Accepted
time: 1ms
memory: 10084kb

input:

ABCABC
ABC

output:

7

result:

ok single line: '7'

Test #4:

score: 0
Accepted
time: 1ms
memory: 9984kb

input:

ABCABC
ABCABC

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 0ms
memory: 10100kb

input:

FUSBX
UUUUUUUUUU

output:

8

result:

ok single line: '8'

Test #6:

score: 0
Accepted
time: 0ms
memory: 10044kb

input:

IWN
NNNNNNNNNN

output:

3

result:

ok single line: '3'

Test #7:

score: 0
Accepted
time: 0ms
memory: 10200kb

input:

RMRMRMRMRMRMRMRMRMRMR
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMR

output:

210

result:

ok single line: '210'

Test #8:

score: 0
Accepted
time: 1ms
memory: 10076kb

input:

TY
YT

output:

1

result:

ok single line: '1'

Test #9:

score: 0
Accepted
time: 1ms
memory: 10072kb

input:

WZ
ZW

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 4ms
memory: 50520kb

input:

SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBWGVXPWAXMSBSB
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS...

output:

1121

result:

ok single line: '1121'

Test #11:

score: 0
Accepted
time: 6ms
memory: 48004kb

input:

TGJPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPX
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

897

result:

ok single line: '897'

Test #12:

score: 0
Accepted
time: 30ms
memory: 10172kb

input:

MKZOLDYLGAULULULUGASEAOZVIHNMRGKZQEIQYTGEMLBMAULULULULULULULPNERGKYZARPULULULULULAOZLQGYHULULULULZKYZUXEBVXZBULULULULULULULULULULULULULULULULDCEXCSTHQRULULULULULULULULULULULULULULULULULRDMPBDULULULUFVXWEMTULULULULULULULULULULULULULULULULULULULULCLULULULULULULULULULULULULULULULULULULULULULULULULULULU...

output:

46504613

result:

ok single line: '46504613'

Test #13:

score: 0
Accepted
time: 28ms
memory: 10212kb

input:

VEPZEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEM...

output:

43715406

result:

ok single line: '43715406'

Test #14:

score: 0
Accepted
time: 28ms
memory: 47784kb

input:

HKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKFBIAHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKIHKHKHKHKHKHKHKHKHKHKHKBHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHK...

output:

45393402

result:

ok single line: '45393402'

Test #15:

score: 0
Accepted
time: 37ms
memory: 50624kb

input:

ZHJDKBQNJPACACACACACACACACACACACACACACACACACACACACACACACEZACACACACACACACBLCRDQEACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACGUEKSAJOFACACACACACACACACACACACACACACACACACACACACACACKHUIOCNKXMKUOKACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACRACACACACACACACACACA...

output:

45452856

result:

ok single line: '45452856'

Test #16:

score: 0
Accepted
time: 31ms
memory: 47912kb

input:

CXQKRAVWKJFOHVJVMNSBGOEJZFAESPYDZCLUOHLBQEHIDLWQWQWQWQWQWQWQRETGMKPFZQWQWQWQWQWQWQWQWQWQWQWQWQWQWQWQSWLXQVWQWQWQWQWQWQWQWQVEHITSVRXBHEWCARSTKQZERXDNJTXGIHTBMCVYSKPSFYIDRGAIEVSTJGUBGMSQFXGWQFHBCTMGOWQWQWQWQWQWQWQPEYDLNUGDIOEKHRNSROPWQWQWQWQWQWQWQWQWQCMSPXODTIKOZYPFHROYFECRUJDWQWQWQWQWQWQWQWQWQWQJUWJK...

output:

49328004

result:

ok single line: '49328004'

Test #17:

score: 0
Accepted
time: 40ms
memory: 47904kb

input:

CBFKLKDEFBGHCEAMJIKGMLJFDKFIDJAKIADCHEJAMJBIFBJCEJCKDFLAFMEGDAMHLDCFGDBJDKLGIDCBMAFBMLFDJGAMLEAHBCIDLFJKCGHILCEDBLKIDMJDICBMFKLDKGLKMLFGKIDGHJIKJHBAJFMLJMEHGFEGAHBJLEBHKAJCKADEFGIEMGKCGMBEJKCFGAIMJBDGFHEMAELCDHCFJGAKEBJFHBDMKEMCJIKLGMCFJGDFLBACHECJMECIDGBKJHMEHILCKIBCLIFMHJFDGAILEBGIAJIFCILFJBLFALGB...

output:

0

result:

ok single line: '0'

Test #18:

score: 0
Accepted
time: 1ms
memory: 9976kb

input:

JIDABCASN
ABCBABCBC

output:

0

result:

ok single line: '0'

Test #19:

score: 0
Accepted
time: 1ms
memory: 10112kb

input:

ASFJABCSFN
ABCABC

output:

0

result:

ok single line: '0'

Test #20:

score: 0
Accepted
time: 8ms
memory: 57188kb

input:

ELUNVXDGQHAYMVWAYBQUJIMOFNOVPTALPHTWCPDMALKAZEAPXFMZCTLKHFIYPUOYKIVLNGHTXSJNIHZURWNYNXBMWOVZYXAQDKFWTHCYVQNFMNIQRFWKTQYHAVJOXNMPTIRWLJXERAWFSZKVOWTNXOTXSTWIGNCEKWDEADLSWHCQDPECUXEKAFEHPKHLTHPFYLUBXGMKENZTOQZKAESFNIQAKUVWPNQAPEHAVIWFAOIXMBPJITYOLTKYGAWKBDOZJUFOVCPGDFZLFQIGEBDEMNUPYEKWSCGDOUWEOJXMAHGZ...

output:

0

result:

ok single line: '0'

Test #21:

score: 0
Accepted
time: 16ms
memory: 83332kb

input:

QAUFICKQDARDZBSWEMXFDPAUJVBDHVTAZDJRMXVNQYBWJLOSONYGXZNKURCGHMXFGZSQIGSRMPSDJGLFUWZJVMDAGUFOXIFHCTWLMLTSMJLOSCLYEYEXZKBEVMORHAGMKCMPIBZXCMNVOEXBJOYBHMVZHBYMVBFLNZPSDZBUEOCZJHZEAUZREVNLIDNHCYBJVBGPSVKSNHTUONLREOIPVTRXIZAYRAPZVYENZVXYIWZLQOVTGZPUAMBSWFVIUHJNACLOFVGNSKPMTSYLVTUIPWKVJYLWKGWZBGCEBVDYTVYI...

output:

0

result:

ok single line: '0'

Test #22:

score: 0
Accepted
time: 33ms
memory: 64076kb

input:

BIUBEMOYSEHTDAYBGSTIEGZAFLQFRKXZHKMLIZORXMYPRIPZVSBPVJYHMFBKVIFXAYFJQCPEGPERASKTJFNYVXNXALJGSABVIEURYVHBVEIAZUXSPANGABQRZHTKQJBTEWLGSTAMEFSZHBZOFDWPXMAZYDPIWXSIMYELONUAJXHBZWSFKEABYQKFRIWYVIFQBLSQJKRTLONRQBJARCKJTKGFIWFRDNYICDQXLIJUVXZNJKGQTEUXGHAEYHWBXYCOSMTPIXRYKIGQLMJCYDIKSPZMCSEHWRHAXEQCZYHXOSWU...

output:

0

result:

ok single line: '0'

Test #23:

score: 0
Accepted
time: 54ms
memory: 75944kb

input:

TGZBZAEQDTWERZFYHZPTVHCLFIVBCOTZAKVSXYUXHLCRIDGLJEWULEVJEZSXUCPXBPCVLACGKCLNRPLVPUWKSOWXREVIHXDSQWCLYEBHOMDYHGQVZADJOSQMBUSKGVEQOMKLBCWNUGOLFZXEPRCZKWJXEZVOWNGVEDQYJIECTMQHXOVPYZDUBZMFBJWZHMAVMWZPFUYXVKLERIPRVMWYUSOZFYAKDZMQDEUSGMVSDHBYFIPOGKIAYHRTBYPGOXMGYSRHWRIZBIZWQITLFKYRWASGAPLUFMIUZJTRVYJLZCQV...

output:

0

result:

ok single line: '0'

Test #24:

score: 0
Accepted
time: 11ms
memory: 37456kb

input:

AIEYDRNKWSEGPLDXVHXFMSJGUQFVNRXTQPVQZHWEHUBVAUPUTCQJYTEBJWEULSDIPVQPNGIODAZRSUQFYEMZEQDALGHMNLETNXTNECTOQGIEVAJFPATYDXIHEGAPMRQUTGCNUTJHFSZJDIUFXHBEMWHDCIYJUGYTHOCEZRTHXWHEWFIVONEGUMKGIENRALWBJLSQAYOFZLBXMAOXPIMTSJEFZEGNMQSPUCZHMRDNVPKJVATROZAQGFOWCTUVKOMVWDAXLRMOZHNEAHUOKEDSYJRAWQLMRUDQCXOTBQOXGRBG...

output:

0

result:

ok single line: '0'

Test #25:

score: 0
Accepted
time: 97ms
memory: 65124kb

input:

ZJPVDHIXEZCWVXWOZYEILQHRPRQZORZQBLIXHCKPGJYIZDBZDENDLPHYRMAONHOAKTHMTKHJBFJYRKQTHLZHTPKJQSXZEHRQGBPRWDMFHWTJZTJCEYLZAJCMEKXHJORTJMFHNAEMJBOLTUYXVLXCZFUNRIGVESCBHSVGUXRMUKIRCAXCIYSCLYCBADRGTQGZTWDBMOEWHPFRXPISNECTFVQRJZUJRGLYMOWHFZDXAMHTCRLXPOMKCXSVGKHJVLDRAHDYMWHURFOJCYPLVYLVUMAZDEHCNBOQWBYIPMDYXUTO...

output:

0

result:

ok single line: '0'

Test #26:

score: 0
Accepted
time: 120ms
memory: 71596kb

input:

QKNDNBUGVUTWQVNETHRWEUWFHJEYGKLAHKSALTHQCTSPFOUMTGWSGCLYIQDPERLHMXZQIAFBVGDQRJWPCFTRQSNRYVPRYCHQUBCYHRAMQXFBXMVXCPXVOIFUYZVOAFMARDSEQPENUAEQWVNBMVJXTBKYTEMCSOPHSRDMWZPQLWVLIAPWNRVQCNBEXGWZXOFRKBJFCUQWNCRURAQLFPSXBSUOFQCRGCVGQYDHXBESHMZJOTLXAUOECHBOEDHRIJRAHELBYXWSQGPXITSRKDNFXSTZYXHSGIPWAZMDUZIXVJGU...

output:

0

result:

ok single line: '0'

Test #27:

score: -100
Time Limit Exceeded

input:

ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:


result: