QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296222#7955. Tandem Copydefyers#WA 2ms5016kbC++171.9kb2024-01-02 14:50:502024-01-02 14:50:50

Judging History

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

  • [2024-01-02 14:50:50]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5016kb
  • [2024-01-02 14:50:50]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

using ll = long long;
using pii = pair<int, int>;

string condense(string t){
	string res;
	for(char c : t){
		res.push_back(c);
		if(res.size() >= 2 && res[res.size() - 1] == res[res.size() - 2])
			res.pop_back();
		if(res.size() >= 4 && res[res.size() - 1] == res[res.size() - 3]
							+ res[res.size() - 2] == res[res.size() - 4])
			res.pop_back(), res.pop_back();
	}
	return res;
}

const int N = 1e5 + 11;
typedef unsigned long long ull;
ull X = 145849, ps[N], pt1[N], pt2[N], pw[N];
int R[N];
int f(string s, string t1, string t2){
	if(s.size() < t1.size()) return 0;
	pw[0] = 1; for(int i = 1; i < N; i++) pw[i] = pw[i - 1] * X;
	ps[0] = 0; for(int i = 0; i < s.size(); i++) ps[i + 1] = ps[i] * X + s[i];
	pt1[0] = 0; for(int i = 0; i < t1.size(); i++) pt1[i + 1] = pt1[i] * X + t1[i];
	pt2[0] = 0; for(int i = 0; i < t2.size(); i++) pt2[i + 1] = pt2[i] * X + t2[i];
	for(int i = 0; i < s.size(); i++) R[i] = s.size();
	for(int i = 0; i <= s.size() - t1.size(); i++){
		if(ps[i + t1.size()] - ps[i] * pw[t1.size()] == pt1[t1.size()]){
			R[i] = i + t1.size() - 1;
		}
	}
	for(int i = 0; i <= s.size() - t2.size(); i++){
		if(ps[i + t2.size()] - ps[i] * pw[t2.size()] == pt2[t2.size()]){
			R[i] = i + t2.size() - 1;
		}
	}
	for(int i = (int) s.size() - 2; i >= 0; i--){
		R[i] = min(R[i], R[i + 1]);
	}
	int ans = 0;
	for(int i = 0; i < s.size(); i++){
		ans += s.size() - R[i];
	}
	return ans;
}

void solve(int TC) {
	string s, t; cin >> s >> t;
	t = condense(t);
	int ans = 0;
	if(t.size() == 2){
		string t1 = t;
		reverse(t.begin(), t.end());
		ans += f(s, t1, t);
	}else{
		ans += f(s, t, t); 
	}
	cout << ans << '\n';
}

int32_t main() {
	cin.tie(0)->sync_with_stdio(0);
	cout << fixed << setprecision(10);

	int t = 1;
	// cin >> t;

	for (int i = 1; i <= t; i++) {
		solve(i);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

ACGCG
CCG

output:

9

result:

ok single line: '9'

Test #2:

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

input:

TATCGC
TTCCG

output:

6

result:

ok single line: '6'

Test #3:

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

input:

ABCABC
ABC

output:

7

result:

ok single line: '7'

Test #4:

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

input:

ABCABC
ABCABC

output:

1

result:

ok single line: '1'

Test #5:

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

input:

FUSBX
UUUUUUUUUU

output:

8

result:

ok single line: '8'

Test #6:

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

input:

IWN
NNNNNNNNNN

output:

3

result:

ok single line: '3'

Test #7:

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

input:

RMRMRMRMRMRMRMRMRMRMR
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMR

output:

210

result:

ok single line: '210'

Test #8:

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

input:

TY
YT

output:

1

result:

ok single line: '1'

Test #9:

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

input:

WZ
ZW

output:

1

result:

ok single line: '1'

Test #10:

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

input:

SBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBSBWGVXPWAXMSBSB
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS...

output:

1121

result:

ok single line: '1121'

Test #11:

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

input:

TGJPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPX
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP...

output:

897

result:

ok single line: '897'

Test #12:

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

input:

MKZOLDYLGAULULULUGASEAOZVIHNMRGKZQEIQYTGEMLBMAULULULULULULULPNERGKYZARPULULULULULAOZLQGYHULULULULZKYZUXEBVXZBULULULULULULULULULULULULULULULULDCEXCSTHQRULULULULULULULULULULULULULULULULULRDMPBDULULULUFVXWEMTULULULULULULULULULULULULULULULULULULULULCLULULULULULULULULULULULULULULULULULULULULULULULULULULU...

output:

46504613

result:

ok single line: '46504613'

Test #13:

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

input:

VEPZEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEMEM...

output:

43715406

result:

ok single line: '43715406'

Test #14:

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

input:

HKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKFBIAHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKIHKHKHKHKHKHKHKHKHKHKHKBHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHK...

output:

45393402

result:

ok single line: '45393402'

Test #15:

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

input:

ZHJDKBQNJPACACACACACACACACACACACACACACACACACACACACACACACEZACACACACACACACBLCRDQEACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACGUEKSAJOFACACACACACACACACACACACACACACACACACACACACACACKHUIOCNKXMKUOKACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACRACACACACACACACACACA...

output:

45452856

result:

ok single line: '45452856'

Test #16:

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

input:

CXQKRAVWKJFOHVJVMNSBGOEJZFAESPYDZCLUOHLBQEHIDLWQWQWQWQWQWQWQRETGMKPFZQWQWQWQWQWQWQWQWQWQWQWQWQWQWQWQSWLXQVWQWQWQWQWQWQWQWQVEHITSVRXBHEWCARSTKQZERXDNJTXGIHTBMCVYSKPSFYIDRGAIEVSTJGUBGMSQFXGWQFHBCTMGOWQWQWQWQWQWQWQPEYDLNUGDIOEKHRNSROPWQWQWQWQWQWQWQWQWQCMSPXODTIKOZYPFHROYFECRUJDWQWQWQWQWQWQWQWQWQWQJUWJK...

output:

49328004

result:

ok single line: '49328004'

Test #17:

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

input:

CBFKLKDEFBGHCEAMJIKGMLJFDKFIDJAKIADCHEJAMJBIFBJCEJCKDFLAFMEGDAMHLDCFGDBJDKLGIDCBMAFBMLFDJGAMLEAHBCIDLFJKCGHILCEDBLKIDMJDICBMFKLDKGLKMLFGKIDGHJIKJHBAJFMLJMEHGFEGAHBJLEBHKAJCKADEFGIEMGKCGMBEJKCFGAIMJBDGFHEMAELCDHCFJGAKEBJFHBDMKEMCJIKLGMCFJGDFLBACHECJMECIDGBKJHMEHILCKIBCLIFMHJFDGAILEBGIAJIFCILFJBLFALGB...

output:

0

result:

ok single line: '0'

Test #18:

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

input:

JIDABCASN
ABCBABCBC

output:

0

result:

ok single line: '0'

Test #19:

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

input:

ASFJABCSFN
ABCABC

output:

0

result:

ok single line: '0'

Test #20:

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

input:

ELUNVXDGQHAYMVWAYBQUJIMOFNOVPTALPHTWCPDMALKAZEAPXFMZCTLKHFIYPUOYKIVLNGHTXSJNIHZURWNYNXBMWOVZYXAQDKFWTHCYVQNFMNIQRFWKTQYHAVJOXNMPTIRWLJXERAWFSZKVOWTNXOTXSTWIGNCEKWDEADLSWHCQDPECUXEKAFEHPKHLTHPFYLUBXGMKENZTOQZKAESFNIQAKUVWPNQAPEHAVIWFAOIXMBPJITYOLTKYGAWKBDOZJUFOVCPGDFZLFQIGEBDEMNUPYEKWSCGDOUWEOJXMAHGZ...

output:

0

result:

ok single line: '0'

Test #21:

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

input:

QAUFICKQDARDZBSWEMXFDPAUJVBDHVTAZDJRMXVNQYBWJLOSONYGXZNKURCGHMXFGZSQIGSRMPSDJGLFUWZJVMDAGUFOXIFHCTWLMLTSMJLOSCLYEYEXZKBEVMORHAGMKCMPIBZXCMNVOEXBJOYBHMVZHBYMVBFLNZPSDZBUEOCZJHZEAUZREVNLIDNHCYBJVBGPSVKSNHTUONLREOIPVTRXIZAYRAPZVYENZVXYIWZLQOVTGZPUAMBSWFVIUHJNACLOFVGNSKPMTSYLVTUIPWKVJYLWKGWZBGCEBVDYTVYI...

output:

0

result:

ok single line: '0'

Test #22:

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

input:

BIUBEMOYSEHTDAYBGSTIEGZAFLQFRKXZHKMLIZORXMYPRIPZVSBPVJYHMFBKVIFXAYFJQCPEGPERASKTJFNYVXNXALJGSABVIEURYVHBVEIAZUXSPANGABQRZHTKQJBTEWLGSTAMEFSZHBZOFDWPXMAZYDPIWXSIMYELONUAJXHBZWSFKEABYQKFRIWYVIFQBLSQJKRTLONRQBJARCKJTKGFIWFRDNYICDQXLIJUVXZNJKGQTEUXGHAEYHWBXYCOSMTPIXRYKIGQLMJCYDIKSPZMCSEHWRHAXEQCZYHXOSWU...

output:

0

result:

ok single line: '0'

Test #23:

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

input:

TGZBZAEQDTWERZFYHZPTVHCLFIVBCOTZAKVSXYUXHLCRIDGLJEWULEVJEZSXUCPXBPCVLACGKCLNRPLVPUWKSOWXREVIHXDSQWCLYEBHOMDYHGQVZADJOSQMBUSKGVEQOMKLBCWNUGOLFZXEPRCZKWJXEZVOWNGVEDQYJIECTMQHXOVPYZDUBZMFBJWZHMAVMWZPFUYXVKLERIPRVMWYUSOZFYAKDZMQDEUSGMVSDHBYFIPOGKIAYHRTBYPGOXMGYSRHWRIZBIZWQITLFKYRWASGAPLUFMIUZJTRVYJLZCQV...

output:

0

result:

ok single line: '0'

Test #24:

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

input:

AIEYDRNKWSEGPLDXVHXFMSJGUQFVNRXTQPVQZHWEHUBVAUPUTCQJYTEBJWEULSDIPVQPNGIODAZRSUQFYEMZEQDALGHMNLETNXTNECTOQGIEVAJFPATYDXIHEGAPMRQUTGCNUTJHFSZJDIUFXHBEMWHDCIYJUGYTHOCEZRTHXWHEWFIVONEGUMKGIENRALWBJLSQAYOFZLBXMAOXPIMTSJEFZEGNMQSPUCZHMRDNVPKJVATROZAQGFOWCTUVKOMVWDAXLRMOZHNEAHUOKEDSYJRAWQLMRUDQCXOTBQOXGRBG...

output:

0

result:

ok single line: '0'

Test #25:

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

input:

ZJPVDHIXEZCWVXWOZYEILQHRPRQZORZQBLIXHCKPGJYIZDBZDENDLPHYRMAONHOAKTHMTKHJBFJYRKQTHLZHTPKJQSXZEHRQGBPRWDMFHWTJZTJCEYLZAJCMEKXHJORTJMFHNAEMJBOLTUYXVLXCZFUNRIGVESCBHSVGUXRMUKIRCAXCIYSCLYCBADRGTQGZTWDBMOEWHPFRXPISNECTFVQRJZUJRGLYMOWHFZDXAMHTCRLXPOMKCXSVGKHJVLDRAHDYMWHURFOJCYPLVYLVUMAZDEHCNBOQWBYIPMDYXUTO...

output:

0

result:

ok single line: '0'

Test #26:

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

input:

QKNDNBUGVUTWQVNETHRWEUWFHJEYGKLAHKSALTHQCTSPFOUMTGWSGCLYIQDPERLHMXZQIAFBVGDQRJWPCFTRQSNRYVPRYCHQUBCYHRAMQXFBXMVXCPXVOIFUYZVOAFMARDSEQPENUAEQWVNBMVJXTBKYTEMCSOPHSRDMWZPQLWVLIAPWNRVQCNBEXGWZXOFRKBJFCUQWNCRURAQLFPSXBSUOFQCRGCVGQYDHXBESHMZJOTLXAUOECHBOEDHRIJRAHELBYXWSQGPXITSRKDNFXSTZYXHSGIPWAZMDUZIXVJGU...

output:

0

result:

ok single line: '0'

Test #27:

score: 0
Accepted
time: 2ms
memory: 5016kb

input:

ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

0

result:

ok single line: '0'

Test #28:

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

input:

CBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

0

result:

ok single line: '0'

Test #29:

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

input:

ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

0

result:

ok single line: '0'

Test #30:

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

input:

INBHJGLCDJGRSNWHTXFEGIAWVWXROMSYXZTFCBHWTIXCBZEJZFGPZKAXTJFQVDTANSJCETHIPGHFELUHBTZRIOBTMLYMRCQDVNCAUIXQTZKAGMPWLUVJFVAZMRXAOSDYJHYKISJTSMTQYCIFTNHECWDYIWGEVZMLBMUJYOKALXYVUTWVBKDBRIUJGTKMUFHWZOCPNIYONVYHVRGPFCWFJQKDLRXFOGSOXEZBIZEWLNROMXZWIFHDCHFEDMUITXCPLTWQCBLXFJQUZSOHXKLFRPTYPNODIXMSUXNSBQHKAWCJ...

output:

0

result:

ok single line: '0'

Test #31:

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

input:

TFQCDUYXLOYHPUIHIKATDYXRVKLWDBGSHPQTVSBKHONRAKTDJSERAIODSCQOEKCTHAGXRVPHEMOTUBETNUCWDHEOWJPMGKTZCPWVPGRBTWISZHPQABQULBKDQURQHRCMPEKHOLGTQNHFXWPXARBSJNLEPYZVEJSYFVYAQIULITNEFKLGMLWXCVGJSBTNRBQTXOACDVHYLKWZVFAJDNLSBEOWPTZSOGVTJACIUNZJTANFIGQMFLMHSATMPXEOVXLGMOEUZYHNTHVKOMGLJRSMVXQYVOMJEHZGNJVNOGBUCKQF...

output:

0

result:

ok single line: '0'

Test #32:

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

input:

QWKDETMOTCFHWAKLRYCJLQBHMGXEBFEYIFIQYKOURSTXEBXUETDXAQBYKSJIZKWMSIAPSYZQICSJBPSAKUPEFJLMODTHSNBIHLKNGMRQNYLFTVPYUQDPUVINLIMRGSWULQDYQVKRDWHAVQARIWXPFRBFZDFPZVFMUFDRIPSWEQYEQGOXHEOGHEGDRAGHTUYMQJHKGREXHQATPHWGAHYIVAFIQHOPYSRENZKAHBCFVPZKWPIGNIYOUXFQKZURTKIHFOJBMHOLFDWOEJHDVLWZEPDVMCSPWKJEXLEKGBUCOZDI...

output:

0

result:

ok single line: '0'

Test #33:

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

input:

PMONBRZUXLXOMICDOYGCDRILAPJCUISVFCWUXHDUBXTVPGVKAUGYBDRBMXNDWHMSRZFMRXSVDSNZQXBMDUNEYZDWOKAERTSMEYJCLFWYLNHCOQKDLTJPMNCJWLZGKVHERNZQYSFTQGSXDYQRWSDFMRHCFEYHEZBENBQRYMPXDWIBRFGRIGMPWNISLDIYBKIJKTSVJRHZUOWZONHAXTDZIHSABHFXYWLJTADJGREOVSJYTAIUSAJPQUFNXBZVTWONZUODJBNGXFDAODBJGHRQXLMBWTUXFEVZWLJPINSBMGTJ...

output:

0

result:

ok single line: '0'

Test #34:

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

input:

IGOCPESZSKCGJBLHDFKLNBENRFXNQAYFVLNWPTDYFANZMCARIMZKEPWQTYCPJILYNOVJSFEZWOBNJKGSEGFJIQOHUYTHXVKUAISVPRMUXAKXZVJWQMFNWLAQENGTORCLDTRBNZLENSKQFLGMJHWBIUMAQJCUTWRMXYKLXWLSNDSVITYZHCBYGJSRKHPUBQCZSIMEROWVYLAQNLQOYEMGSLTNQETDXZWEQUSMCGALKITMKOIFDQRWYCUTWJVIMSTCOADHIJPLWRKXHGNOMSGPXFADBMZTILHROCSARTLPDRFC...

output:

0

result:

ok single line: '0'

Test #35:

score: -100
Wrong Answer
time: 1ms
memory: 4232kb

input:

UNINININININIUNININIUNINININININININIU
NINININIUNININIU

output:

108

result:

wrong answer 1st lines differ - expected: '216', found: '108'