ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#211111 | #3799. 猫哭 | drdilyor | 52 | 19ms | 31768kb | C++11 | 2.1kb | 2024-08-09 11:48:37 | 2024-08-09 12:50:15 |
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
void ts(){cout<<"IAKIOI\n";}
inline int read(){
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
const int mod=998244353;
struct mint{
int x;mint(int o=0){x=o;}mint&operator+=(mint a){return(x+=a.x)%=mod,*this;}mint&operator-=(mint a){return(x+=mod-a.x)%=mod,*this;}
mint&operator*=(mint a){return(x=1ll*x*a.x%mod),*this;}mint&operator^=( int b){mint a=*this;x=1;while(b)(b&1)&&(*this*=a,1),a*=a,b>>=1;return*this;}
mint&operator/=(mint a){return*this*=(a^=mod-2);}friend mint operator+(mint a,mint b){return a+=b;}friend mint operator-(mint a,mint b){return a-=b;}
friend mint operator*(mint a,mint b){return a*=b;}friend mint operator/(mint a,mint b){return a/=b;}friend mint operator^(mint a,int b){return a^=b;}
mint operator-(){return 0-*this;}bool operator==(const mint b)const{return x==b.x;}
};
char s[1000005];
int dp[505][505][505];
//有多少 TA, 有多少个 T.
void solve(){
scanf("%s",s+1);
int n=0;
int l=strlen(s+1);
for(int i=1;i<=l;i++){
if(s[i]=='C'||s[i]=='A'||s[i]=='T')s[++n]=s[i];
}
reverse(s+1,s+n+1);
for(int i=0;i<=n;i++){
for(int j=0;j<=n;j++)for(int k=0;k<=n;k++)dp[i][j][k]=-(1ll<<60);
}
if(n<=50){
dp[0][0][0]=0;
for(int i=1;i<=n;i++){
for(int j=0;j<=n;j++){
for(int k=0;k<=n;k++){
if(dp[i-1][j][k]<0)continue;
dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k]);
if(s[i]=='A'){
if(k)dp[i][j+1][k-1]=max(dp[i][j+1][k-1],dp[i-1][j][k]);
}
else if(s[i]=='T'){
dp[i][j][k+1]=max(dp[i][j][k+1],dp[i-1][j][k]);
if(j)dp[i][j-1][k]=max(dp[i][j-1][k],dp[i-1][j][k]+1);
}
else{
if(j)dp[i][j-1][k]=max(dp[i][j-1][k],dp[i-1][j][k]+1);
}
}
}
}
int res=0;
for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)res=max(res,dp[n][i][j]);
printf("%lld\n",res);return;
}
}
signed main(){
int t=read();
while(t--)solve();
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 4
Accepted
time: 0ms
memory: 1500kb
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 2 1 0 1 1 1 1 1 1 0
result:
ok 40 tokens
Test #2:
score: 4
Accepted
time: 0ms
memory: 1324kb
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: 4
Accepted
time: 0ms
memory: 2188kb
input:
40 GCATTCTACCAGAGT TGGGTATAAATTTCT AAACCCTGTTTTTAC TCCCATCTCAATCTG CATCGCTTTAAACTT TACACGATTCATCAC T...
output:
2 3 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 3 2 2 2 2 2 2
result:
ok 40 tokens
Test #4:
score: 4
Accepted
time: 0ms
memory: 2192kb
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: 1280kb
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: 4
Accepted
time: 3ms
memory: 11464kb
input:
10 TAATTCCTACCTCTATAATAATACCCCACCCTACATCAATCGAATTTCAA CACATAAATCCCCATCTAGTTCAGCTTTTTCTATAAACATAATATC...
output:
11 12 6 9 9 13 8 10 11 7
result:
ok 10 tokens
Test #7:
score: 4
Accepted
time: 5ms
memory: 11064kb
input:
10 ATATATCTGCTAGTCTTCGCCGCTACATAACGCTACTACGAATTGCAACC TGATATCCTTCCCTTAGTTTATCATTGATATTATCACACAAAAATT...
output:
8 12 12 11 10 11 13 10 10 12
result:
ok 10 tokens
Test #8:
score: 4
Accepted
time: 4ms
memory: 11064kb
input:
10 CGACGCCCTAACAAGCACGAACCTTTTTGCAACAGATATTCACAAATATG TTATACCTTCACACTTTACTACATACAGCACTCGAAAGAAAGATCA...
output:
11 9 11 12 11 7 11 9 10 8
result:
ok 10 tokens
Test #9:
score: 4
Accepted
time: 2ms
memory: 11060kb
input:
10 GAACAAACCATTGAGTTCATTGCACATCCGATACCTAAAAAACACTACAT ACCCAGATCTACTCTCTTCTAACACTGATTGACAATTTGCTGAACC...
output:
9 10 9 9 5 11 11 11 7 13
result:
ok 10 tokens
Test #10:
score: 4
Accepted
time: 0ms
memory: 9540kb
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: 4
Accepted
time: 0ms
memory: 11060kb
input:
19 TGCTTCCTGCATCGAAATGT CACAAGTGAAATTGTTTACT TGTTCAAACCAACCCTCTTC ACTCTACCTGTCGCCAAATA TGACACCTCATCG...
output:
3 4 3 2 3 4 4 4 2 1 4 2 3 3 3 8 11 13 10
result:
ok 19 tokens
Test #12:
score: 4
Accepted
time: 0ms
memory: 1656kb
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: 1656kb
input:
10 DOEHWYGHXGOJAQHEFUFFVAKMLNHMOXSUZWMNATIULQZQMCWZJA NXJHYTEVCSYBGVASDYEQFCAYDXPYNDJQQJWLNJOWNOIWRX...
output:
0 0 0 1 0 0 1 0 0 1
result:
ok 10 tokens
Test #14:
score: 0
Memory Limit Exceeded
input:
62 AAATTTTTTTTATTTATTATTTTTTTTAATAAATTATATAATATTTTTAATTATTTTTTATTAATTTTAATTATTAATTATATTAAATTTTATTTAT...
output:
result:
Test #15:
score: 0
Memory Limit Exceeded
input:
5 TTATAATTTTTTTATTTTTTATTTATTTATTTAATATTTTTTATTTATTAAATATAATTTTTTATTTTTTTATTATTTAAATTTTTTATATAAAATAA...
output:
result:
Test #16:
score: 0
Memory Limit Exceeded
input:
5 TTATTATATTATTTTTTTATTAAATTATTTATATAAATAAATTATTTTTATTTTATTTTATTATTTTTATTTATTATTTTTTTATTTAAAAATTTTAT...
output:
result:
Test #17:
score: 0
Memory Limit Exceeded
input:
5 TAATTTATTTTATTTATTAAATTTTTATTTTAATAATATTTTAATTATTTATATTTTATTAATAATAATTTTTTTATTTAAATTTAATTATTTTTTTA...
output:
result:
Test #18:
score: 0
Memory Limit Exceeded
input:
5 TTTATTTTTTTTTATTTTTATTTATTTAATTTATAATATTATTTTTTTTATAATTTTTTTTTTTTTATAAAATATTTTTATTTTTTTAATATATTTTT...
output:
result:
Test #19:
score: 0
Memory Limit Exceeded
input:
62 ATTTTTTTATATTTTTTTTTTTTTATTTTTATTATTATTATTTTTATTTA ATTATATTTTATTAATTTTTAATTTTTTATTTTAATTTTAATTAAT...
output:
result:
Test #20:
score: 0
Memory Limit Exceeded
input:
110 TATTAAATATATTAAATTTTTTTTATTAATTTATTATTTATTATTATATTATATTTTTTATATTTTTATAAAAATTTATTTTATTTATAATTAATA...
output:
result:
Test #21:
score: 0
Memory Limit Exceeded
input:
110 ATATATTTTTAATTTTTTAT TTTTTTTAATTTTTATTATT TTTATAAATAAAATTTTTTT AATATTTATAATAATTTTAT AAATTTATAATA...
output:
result:
Test #22:
score: 0
Wrong Answer
time: 4ms
memory: 31768kb
input:
5 SXKKWHGPZMREKWJWXIEXUZXLQGVRPQKXQLASTFLUAPAPUSLGRPEINOXUBSXJLAQHQFNXPPBZZAJLXRIQTPNVJPJVAWXWINTTKO...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #23:
score: 0
Time Limit Exceeded
input:
2 TATATACAACATCTAGATCTCACTTGATTTCACTATTCAATTCCCATGTCCATACAACCGACTCAAATTCTAATTTTAGATTTACTAACCCATTACCG...
output:
result:
Test #24:
score: 0
Time Limit Exceeded
input:
2 CCTGTCTATCAACCTCTAACACATAATCGGACTATGACCACTTGATTTTACCACTACCAGCTCAAATGAACACACTCTCTTTTCTTATTACTATCAAC...
output:
result:
Test #25:
score: 0
Time Limit Exceeded
input:
2 TACCAACCTACTCGAGCTCCCTCTACAATTACGACTTCCTGAACTACCATACCAAACTGCTCTCGAATTGTATCGACATGATTAAGTCCCAATTCGAT...
output:
result:
Test #26:
score: 0
Time Limit Exceeded
input:
2 CACACATTCTCTCTTATTCAGCCTATCCGTGAAAGTTGACATATATCATGTCAAAATGCCATCTTAACTTAATAACGTAAATCTACCGATCCATTTAT...
output:
result:
Test #27:
score: 0
Time Limit Exceeded
input:
84 ATAGACCCCCCAACACCGCTACTAACTTTCCCTGATTATCCCCTGGCATCTCCATTGTTAAAACGCCCCTATTACGTAATTTTTGCGCGATATTTTA...
output:
result:
Test #28:
score: 0
Time Limit Exceeded
input:
84 CTCCTCACCTTTAACGATCATACTCAATAACAGAACACCATTCGACCCCCTTTAACCATATGCCACGCCTGACTATTTCACTTCCTCCCTTGCCGAT...
output:
result:
Test #29:
score: 0
Time Limit Exceeded
input:
10001 AAAGACGCTCCAACCAGCTATCTTTCCAAATGTTCCTCTACCCTACCTCAGCTTTCGTCCAATCCCAGAACCCTAGTTAATATAACTCTAAATA...
output:
result:
Test #30:
score: 0
Memory Limit Exceeded
input:
2501 CGTCCACGTTGTCGCCCACTATATAAACTATCTCCCACTATGAAAGGCCCCTTTTAATAACCTCATCTCTTAAAGATAAATCCCTAATTACCCTA...
output:
result:
Test #31:
score: 0
Time Limit Exceeded
input:
100000 TAAATTTACTACTCCTACCA AACACATAAAACGCTTCTCA CATATCTAAAAATAAACCTC CGTCCCAACCTACCTCGCCT TACGACCCA...
output:
3 3 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:
Test #32:
score: 0
Time Limit Exceeded
input:
250005 TAGCAAATTTTACATAGCAATAATCACATAACTTACCTCATACTATAATAGAATCATTAACACCATGCCATCCCCTCTCATGTATACCTCTTT...
output:
result:
Test #33:
score: 0
Memory Limit Exceeded
input:
1001 TAATACCTTCCCCCTTAATGAACCCATAGACCTTTCCCTTTAATAATTCTAATACAACCCTGGCCCCACACACAAATATAAACCAGGGTCAAAAA...
output:
result:
Test #34:
score: 0
Time Limit Exceeded
input:
2 NPPZPXGAOITHNUMEIZSXQMQAZPYNBVBKYSJGJDMGEYQRYSPFBKJOJYIFRAJWFCQYOATYKHTBWXAKPVKFAXJBDBWIXDUBGRMGVG...