UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#211145#3799. 猫哭mygr24442ms3468kbC++11807b2024-08-09 12:26:222024-08-09 12:57:04

answer

#include<bits/stdc++.h>
using namespace std;
int T;
string s;
stack<int> C,T1,T2;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>T;
	while(T--)
	{
		int ans=0;
		cin>>s;
		for(int i=(int)s.size()-1;i>=0;i--)
		{
			if(s[i]=='T')
				T1.push(i);
		}
		for(int i=0;i<=(int)s.size()-1;i++)
		{
			if(s[i]=='C')
				C.push(i);
			while(!T1.empty() and T1.top()<=i)
			{
				T2.push(T1.top());
				T1.pop();
			}
			if(s[i]=='A')
			{
				if(!C.empty() and!T1.empty())
				{
					ans++;
					C.pop();
					T1.pop();
				}
				else if(!T1.empty() and !T2.empty())
				{
					ans++;
					T1.pop();
					T2.pop();
				}
			}
		}
		printf("%d\n",ans);
		while(!C.empty())C.pop();
		while(!T1.empty())T1.pop();
		while(!T2.empty())T2.pop();
	}
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1272kb

input:

40
CCCATGCA
CCTATCAT
GTCTGCTA
ACACCTCC
TTATAACA
ATGATCAT
TATTACCA
CAAGCACC
CTCTCCTC
CTTTAAAT
CACTTCC...

output:

1
2
0
1
1
2
1
0
0
1
1
1
1
1
1
1
1
1
2
1
0
1
1
0
0
0
1
1
1
1
1
1
0
1
1
1
1
1
1
0

result:

wrong answer 31st words differ - expected: '2', found: '1'

Test #2:

score: 4
Accepted
time: 1ms
memory: 1272kb

input:

40
GTACT
CATCT
ATAAT
TCAGT
ATTCG
ACTTT
TCCGA
CACTA
TGATC
TGTCA
AATAT
AACCT
TATCT
TCCTC
ATATG
AGTCA
C...

output:

1
1
1
1
0
0
0
1
1
0
1
0
1
0
1
0
1
1
0
0
0
0
0
0
0
1
0
0
1
1
0
1
0
0
1
1
1
1
0
1

result:

ok 40 tokens

Test #3:

score: 0
Wrong Answer
time: 1ms
memory: 1268kb

input:

40
GCATTCTACCAGAGT
TGGGTATAAATTTCT
AAACCCTGTTTTTAC
TCCCATCTCAATCTG
CATCGCTTTAAACTT
TACACGATTCATCAC
T...

output:

2
2
0
3
3
3
2
2
2
1
3
2
3
2
2
2
3
3
2
1
4
2
3
1
1
1
2
2
3
2
2
1
2
2
1
2
2
2
2
2

result:

wrong answer 2nd words differ - expected: '3', found: '2'

Test #4:

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

input:

40
TAGACACTATCTTCC
CCTATCCCATACAAT
AGTCTTACCGCTCCA
AGCTCAAATAAATCA
GAACACCCCAAACAA
ATACCAACTCATCAA
C...

output:

3
3
1
2
0
2
4
4
2
1
3
2
0
3
1
3
2
1
4
2
2
2
2
2
3
2
3
2
2
1
3
2
3
2
3
2
1
1
2
0

result:

ok 40 tokens

Test #5:

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

input:

40
EJUPFQZTAJCKRQD
UMDIIZLTKGXGUUY
RNFTZBNKAYNSWZT
KEGHKRLQWKXJFSI
XZLUPCKNWHVBDZO
LYBUUCYFIUGEECF
Z...

output:

0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 40 tokens

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 1264kb

input:

10
TAATTCCTACCTCTATAATAATACCCCACCCTACATCAATCGAATTTCAA
CACATAAATCCCCATCTAGTTCAGCTTTTTCTATAAACATAATATC...

output:

11
11
6
9
9
13
8
10
11
7

result:

wrong answer 2nd words differ - expected: '12', found: '11'

Test #7:

score: 0
Wrong Answer
time: 0ms
memory: 1264kb

input:

10
ATATATCTGCTAGTCTTCGCCGCTACATAACGCTACTACGAATTGCAACC
TGATATCCTTCCCTTAGTTTATCATTGATATTATCACACAAAAATT...

output:

7
11
10
11
10
11
13
10
10
12

result:

wrong answer 1st words differ - expected: '8', found: '7'

Test #8:

score: 0
Wrong Answer
time: 0ms
memory: 1268kb

input:

10
CGACGCCCTAACAAGCACGAACCTTTTTGCAACAGATATTCACAAATATG
TTATACCTTCACACTTTACTACATACAGCACTCGAAAGAAAGATCA...

output:

11
9
11
12
11
7
9
9
8
8

result:

wrong answer 7th words differ - expected: '11', found: '9'

Test #9:

score: 0
Wrong Answer
time: 2ms
memory: 1264kb

input:

10
GAACAAACCATTGAGTTCATTGCACATCCGATACCTAAAAAACACTACAT
ACCCAGATCTACTCTCTTCTAACACTGATTGACAATTTGCTGAACC...

output:

9
10
9
9
4
11
10
11
7
13

result:

wrong answer 5th words differ - expected: '5', found: '4'

Test #10:

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

input:

19
GACTTACGCCCAAAAATCCCCGAGACGTCACTAAATCTCAAAAATTATTC
CTTCTAAATCTAATCCTATGTCGCCCTCCGCTCTGGGACTATTCTC...

output:

9
9
7
10
4
2
4
4
3
5
4
3
4
4
4
4
2
3
6

result:

ok 19 tokens

Test #11:

score: 0
Wrong Answer
time: 0ms
memory: 1264kb

input:

19
TGCTTCCTGCATCGAAATGT
CACAAGTGAAATTGTTTACT
TGTTCAAACCAACCCTCTTC
ACTCTACCTGTCGCCAAATA
TGACACCTCATCG...

output:

3
3
3
2
3
4
4
4
2
1
4
2
3
3
3
8
11
13
10

result:

wrong answer 2nd words differ - expected: '4', found: '3'

Test #12:

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

input:

50
AAACAAATCT
TCCCAACAAC
TCTCAATTCC
CTCCATCTAA
GATAAACTCA
ACTTACGTTA
CTAATTCCCA
CTCTCACTCA
AATAATGCA...

output:

1
0
2
1
1
1
2
1
1
2
2
1
2
1
1
0
2
2
0
1
1
0
1
0
3
1
3
1
1
1
2
2
2
1
2
0
1
2
1
1
2
1
2
2
1
2
2
2
1
0

result:

ok 50 tokens

Test #13:

score: 4
Accepted
time: 1ms
memory: 1268kb

input:

10
DOEHWYGHXGOJAQHEFUFFVAKMLNHMOXSUZWMNATIULQZQMCWZJA
NXJHYTEVCSYBGVASDYEQFCAYDXPYNDJQQJWLNJOWNOIWRX...

output:

0
0
0
1
0
0
1
0
0
1

result:

ok 10 tokens

Test #14:

score: 0
Wrong Answer
time: 0ms
memory: 1284kb

input:

62
AAATTTTTTTTATTTATTATTTTTTTTAATAAATTATATAATATTTTTAATTATTTTTTATTAATTTTAATTATTAATTATATTAAATTTTATTTAT...

output:

326
321
15
13
13
9
12
14
14
12
16
11
13
12
15
15
12
10
12
9
12
14
12
12
13
12
11
14
14
13
14
7
14
13...

result:

wrong answer 1st words differ - expected: '329', found: '326'

Test #15:

score: 0
Wrong Answer
time: 0ms
memory: 1288kb

input:

5
TTATAATTTTTTTATTTTTTATTTATTTATTTAATATTTTTTATTTATTAAATATAATTTTTTATTTTTTTATTATTTAAATTTTTTATATAAAATAA...

output:

311
318
295
308
322

result:

wrong answer 1st words differ - expected: '313', found: '311'

Test #16:

score: 0
Wrong Answer
time: 0ms
memory: 1284kb

input:

5
TTATTATATTATTTTTTTATTAAATTATTTATATAAATAAATTATTTTTATTTTATTTTATTATTTTTATTTATTATTTTTTTATTTAAAAATTTTAT...

output:

325
315
311
303
300

result:

wrong answer 1st words differ - expected: '333', found: '325'

Test #17:

score: 0
Wrong Answer
time: 0ms
memory: 1284kb

input:

5
TAATTTATTTTATTTATTAAATTTTTATTTTAATAATATTTTAATTATTTATATTTTATTAATAATAATTTTTTTATTTAAATTTAATTATTTTTTTA...

output:

322
315
320
320
295

result:

wrong answer 1st words differ - expected: '323', found: '322'

Test #18:

score: 0
Wrong Answer
time: 0ms
memory: 1288kb

input:

5
TTTATTTTTTTTTATTTTTATTTATTTAATTTATAATATTATTTTTTTTATAATTTTTTTTTTTTTATAAAATATTTTTATTTTTTTAATATATTTTT...

output:

324
317
316
309
301

result:

wrong answer 2nd words differ - expected: '331', found: '317'

Test #19:

score: 0
Wrong Answer
time: 0ms
memory: 1284kb

input:

62
ATTTTTTTATATTTTTTTTTTTTTATTTTTATTATTATTATTTTTATTTA
ATTATATTTTATTAATTTTTAATTTTTTATTTTAATTTTAATTAAT...

output:

8
15
15
11
12
9
11
11
16
12
9
13
15
11
14
12
15
15
12
12
14
14
13
14
14
9
14
10
14
14
13
13
13
12
13...

result:

wrong answer 5th words differ - expected: '14', found: '12'

Test #20:

score: 0
Wrong Answer
time: 0ms
memory: 1272kb

input:

110
TATTAAATATATTAAATTTTTTTTATTAATTTATTATTTATTATTATATTATATTTTTTATATTTTTATAAAAATTTATTTTATTTATAATTAATA...

output:

91
94
93
84
83
96
84
86
89
89
3
4
6
5
5
5
6
4
3
3
3
5
5
5
5
4
6
6
4
6
5
4
4
2
3
4
3
4
5
4
5
5
5
4
2
...

result:

wrong answer 1st words differ - expected: '98', found: '91'

Test #21:

score: 0
Wrong Answer
time: 0ms
memory: 1272kb

input:

110
ATATATTTTTAATTTTTTAT
TTTTTTTAATTTTTATTATT
TTTATAAATAAAATTTTTTT
AATATTTATAATAATTTTAT
AAATTTATAATA...

output:

4
4
3
4
4
5
5
5
3
5
3
5
4
6
5
6
6
6
4
3
4
6
4
5
4
4
5
3
5
4
5
3
5
4
4
3
2
3
6
3
4
5
5
3
3
3
3
5
2
4
...

result:

wrong answer 1st words differ - expected: '5', found: '4'

Test #22:

score: 0
Wrong Answer
time: 1ms
memory: 1272kb

input:

5
SXKKWHGPZMREKWJWXIEXUZXLQGVRPQKXQLASTFLUAPAPUSLGRPEINOXUBSXJLAQHQFNXPPBZZAJLXRIQTPNVJPJVAWXWINTTKO...

output:

17
15
16
24
19

result:

wrong answer 1st words differ - expected: '18', found: '17'

Test #23:

score: 0
Wrong Answer
time: 33ms
memory: 3412kb

input:

2
TATATACAACATCTAGATCTCACTTGATTTCACTATTCAATTCCCATGTCCATACAACCGACTCAAATTCTAATTTTAGATTTACTAACCCATTACCG...

output:

304702
304745

result:

wrong answer 1st words differ - expected: '304734', found: '304702'

Test #24:

score: 0
Wrong Answer
time: 33ms
memory: 3416kb

input:

2
CCTGTCTATCAACCTCTAACACATAATCGGACTATGACCACTTGATTTTACCACTACCAGCTCAAATGAACACACTCTCTTTTCTTATTACTATCAAC...

output:

304905
304698

result:

wrong answer 1st words differ - expected: '305146', found: '304905'

Test #25:

score: 0
Wrong Answer
time: 38ms
memory: 3416kb

input:

2
TACCAACCTACTCGAGCTCCCTCTACAATTACGACTTCCTGAACTACCATACCAAACTGCTCTCGAATTGTATCGACATGATTAAGTCCCAATTCGAT...

output:

304736
304901

result:

wrong answer 2nd words differ - expected: '304948', found: '304901'

Test #26:

score: 0
Wrong Answer
time: 34ms
memory: 3412kb

input:

2
CACACATTCTCTCTTATTCAGCCTATCCGTGAAAGTTGACATATATCATGTCAAAATGCCATCTTAACTTAATAACGTAAATCTACCGATCCATTTAT...

output:

304574
305111

result:

wrong answer 1st words differ - expected: '304589', found: '304574'

Test #27:

score: 0
Wrong Answer
time: 39ms
memory: 1780kb

input:

84
ATAGACCCCCCAACACCGCTACTAACTTTCCCTGATTATCCCCTGGCATCTCCATTGTTAAAACGCCCCTATTACGTAATTTTTGCGCGATATTTTA...

output:

91027
91145
91014
90908
2947
2995
2954
2984
2972
2967
3002
2960
2963
3003
2984
2999
2979
2982
2984
2...

result:

wrong answer 2nd words differ - expected: '91202', found: '91145'

Test #28:

score: 0
Wrong Answer
time: 31ms
memory: 1860kb

input:

84
CTCCTCACCTTTAACGATCATACTCAATAACAGAACACCATTCGACCCCCTTTAACCATATGCCACGCCTGACTATTTCACTTCCTCCCTTGCCGAT...

output:

2933
2955
2951
2935
2981
2992
2981
2991
2975
3002
2979
2995
2959
2883
2955
3007
3020
3029
2951
2984
...

result:

wrong answer 1st words differ - expected: '2938', found: '2933'

Test #29:

score: 0
Wrong Answer
time: 40ms
memory: 3412kb

input:

10001
AAAGACGCTCCAACCAGCTATCTTTCCAAATGTTCCTCTACCCTACCTCAGCTTTCGTCCAATCCCAGAACCCTAGTTAATATAACTCTAAATA...

output:

304838
24
27
23
26
20
22
28
22
25
24
24
26
23
24
24
22
20
19
22
26
25
25
19
27
22
26
23
18
21
20
25
...

result:

wrong answer 3rd words differ - expected: '28', found: '27'

Test #30:

score: 0
Wrong Answer
time: 34ms
memory: 3468kb

input:

2501
CGTCCACGTTGTCGCCCACTATATAAACTATCTCCCACTATGAAAGGCCCCTTTTAATAACCTCATCTCTTAAAGATAAATCCCTAATTACCCTA...

output:

111
105
105
118
104
115
116
93
100
103
99
104
100
110
108
111
110
104
112
99
100
112
106
111
116
107...

result:

wrong answer 3rd words differ - expected: '108', found: '105'

Test #31:

score: 0
Wrong Answer
time: 49ms
memory: 1276kb

input:

100000
TAAATTTACTACTCCTACCA
AACACATAAAACGCTTCTCA
CATATCTAAAAATAAACCTC
CGTCCCAACCTACCTCGCCT
TACGACCCA...

output:

3
2
3
3
1
3
3
4
2
2
4
4
2
3
4
4
4
3
3
2
2
3
1
3
4
2
5
3
4
3
1
3
4
3
5
2
4
5
5
3
3
3
4
3
3
3
2
3
3
0
...

result:

wrong answer 2nd words differ - expected: '3', found: '2'

Test #32:

score: 0
Wrong Answer
time: 62ms
memory: 1416kb

input:

250005
TAGCAAATTTTACATAGCAATAATCACATAACTTACCTCATACTATAATAGAATCATTAACACCATGCCATCCCCTCTCATGTATACCTCTTT...

output:

30378
30327
30320
30264
30252
0
1
0
0
1
0
0
1
1
0
1
0
0
0
0
1
1
1
0
0
1
0
1
1
0
1
0
1
0
1
1
0
0
0
0
...

result:

wrong answer 1st words differ - expected: '30478', found: '30378'

Test #33:

score: 0
Wrong Answer
time: 30ms
memory: 3468kb

input:

1001
TAATACCTTCCCCCTTAATGAACCCATAGACCTTTCCCTTTAATAATTCTAATACAACCCTGGCCCCACACACAAATATAAACCAGGGTCAAAAA...

output:

284
267
279
287
283
261
280
283
278
266
281
281
286
270
272
286
283
293
281
278
289
292
292
281
291
...

result:

wrong answer 2nd words differ - expected: '272', found: '267'

Test #34:

score: 0
Wrong Answer
time: 13ms
memory: 2756kb

input:

2
NPPZPXGAOITHNUMEIZSXQMQAZPYNBVBKYSJGJDMGEYQRYSPFBKJOJYIFRAJWFCQYOATYKHTBWXAKPVKFAXJBDBWIXDUBGRMGVG...

output:

37926
38398

result:

wrong answer 1st words differ - expected: '37993', found: '37926'