QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#31788 | #21644. 基因序列问题 | LFCode | 0 | 7ms | 5700kb | C++14 | 1.2kb | 2022-05-12 16:54:51 | 2022-05-12 16:54:54 |
Judging History
answer
//什么时候我才能有杜爷一半强呀/kk
//烂烂 摆摆 呜呜
#include<cstdio>
#include<iostream>
#include<cstring>
#include<map>
using std::cin;
using std::cout;
using std::map;
const int N=233333;
int n;
char ch[N];
namespace sub1{
unsigned long long P=31;
int p[5050][5050],s[5050][5050];
unsigned long long pw[5050],h1[5050],h2[5050];
unsigned long long gsh(int l,int r){return h1[r]-h1[l-1]*pw[r-l+1];}
unsigned long long ghs(int l,int r){return h2[l]-h2[r+1]*pw[r-l+1];}
int mian(){
pw[0]=1;
for(int i=1;i<=n;i++){
h1[i]=h1[i-1]*P+(ch[i]-'A'+1);
pw[i]=pw[i-1]*P;
}
for(int i=n;i;i--)h2[i]=h2[i+1]*P+(ch[i]-'A'+1);
for(int len=1;len<=n;len++){
map<unsigned long long,int>mp;
for(int l=1;l+len-1<=n;l++){
int r=l+len-1;
if(gsh(l,r)!=ghs(l,r))continue;
s[l][r]++;int x=mp[gsh(l,r)];
if(x)s[x][r]--;mp[gsh(l,r)]=l;
}
}
for(int l=1;l<=n;l++)
for(int r=l;r<=n;r++)
s[l][r]+=s[l][r-1];
for(int l=n;l;l--)
for(int r=l;r<=n;r++)
s[l][r]+=s[l+1][r];
int m=0;cin>>m;
for(int i=1;i<=m;i++){
int l=0,r=0;cin>>l>>r;
cout<<s[l][r]<<'\n';
}
return 0;
}
}
int main(){
cin>>(ch+1);n=strlen(ch+1);
if(n<=5000)return sub1::mian();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 5604kb
input:
CCAAAACAAACACAGAGGAAACAACAACCAGCATAAACACTCAGTAAAACACGAGCACAGGAAAAAGAGAACCAGCCTCCAAAAAACAAACGCAGCACAAACTGCACCAACCGAAACAACACAACCGAAAATCCCAGTCAGGCAAGACACCAAACACGACAAACCAACACAAAAACCTACCAACACACACCAAAAACACAAAGGCTGAAAAACGACCGACCCCGCACGACAACAACAACCAAGAGACGAACCAACAACTAAACACCCAGCACGAACAAAAAACACAAGACCCCAGAAAAA...
output:
result:
wrong answer Answer contains longer sequence [length = 6500], but output contains 0 elements
Test #2:
score: 0
Wrong Answer
time: 3ms
memory: 3544kb
input:
GCCCCCACCAAACCAAATCAAACTAGCACAACCAAAAAAATACAGAACGAACACAGAAAAAACAGGAAAAACAAAGAAACGAAACCCAGTACATAAGGGATAAAAACAAGAAACGAAACCCACAAGAGCAGAAGCAAAAAAAAAACCCACACCTTAAACCCCACACCAACAAAAGCACACAAACACAACACGACCCCCTGAGGAGTAAGCCTCAAAACAACGAACCCAACTCGGAAATCAATATGAAAAAACACCGGAGCACCTCACGCCACAACACCCGAGAAAATCACGCGACCAACC...
output:
result:
wrong answer Answer contains longer sequence [length = 23000], but output contains 0 elements
Test #3:
score: 0
Wrong Answer
time: 3ms
memory: 3628kb
input:
AAACAAGCCAACAAGGACGCCAAAAGCACGCAATACAAGACCACCTGACAAACGAAAACTAACCAAACAGCACGAAAACAGACAAGGAACACAAGGAGAACAAGAAGATAACAAAAACTAGAAAAAAACACCATAACAGCATGCAAAACACAAACCCAAAACAAAAACTTAACAAAAAAAAGACAAGGGCCCACAAAAACAACAAAAAAAACCTCCTGAACAACCGCGGACAACCCGACCCACGCGCGCCCGGACCAACCAAACAAACTAAACCAGAACCCCCCCCGCGCAAAACCAACA...
output:
result:
wrong answer Answer contains longer sequence [length = 23000], but output contains 0 elements
Test #4:
score: 0
Wrong Answer
time: 3ms
memory: 5700kb
input:
AAAAAAACCACACACGAAGCAACGACACATCCAAACGAAAAAAAACAGAAAAGATTAACTCAAAACCAAAAACAAACCAGAGAAGGGGACAGGTAACCGAAATTAAACCCCTGCAACCCAAGCAAAAAAAACCCATACACCCCAGAAGCAAACAAACAGAGAAAGACAACCAGGCGAACTAAAAGAAAAAAACACAACCGGATCAGAACCACACTAAAGCCACCATCAACCGGCCGCGCAAACAAAGCAGCAACAACCACAATAACCATAACAAAAGAAGTAAATACCGCGGCAACAAAA...
output:
result:
wrong answer Answer contains longer sequence [length = 23000], but output contains 0 elements
Test #5:
score: 0
Time Limit Exceeded
input:
AACGCACACATTGAAAAAACACCCCACAAAACGAAACATAAAAAGCGAACAATGACCTCAGAAACAGATACGGAAACAGCCAACGCCAGAACAAACCACATACCCCAGCCGAGAATCGAAAATAGCCACCTCAATGGACCGAACTAGCCACACACGACGAGGCAAGGCAAGAATGAGGCTGGATACCACGAAACTACCCTCAAACCAGACCACCAGCAAACACAGCGCACGAGACAGGGCAGAACACAGCTCCCAAAAACGGCACACGAGCAGATGGCCCAACCACCAAAAAAAAATAGA...
output:
40 230 114 113 161 152 70 168 208 167 131 172 254 19 181 275 125 165 146 137 179 182 170 77 54 208 129 158 90 63 220 90 132 192 86 156 230 234 187 204 34 214 49 202 260 173 149 206 161 155 174 149 123 165 66 101 260 73 5 132 124 101 109 196 38 67 155 17 229 61 186 173 94 150 256 30 237 240 166 62 17...
result:
Test #6:
score: 0
Wrong Answer
time: 4ms
memory: 3540kb
input:
GCAGAACAGGGAAATGCACCCGCCCCCACAACCACCACACACCAGAACTAAGTCTAAACTGGAGAATACAAAACCCCGAAACAATGCGTCCAACAAGCAGCAAAACGTATACGACAACCAAACACACAAACAGAGCCACAACTAAAAACGCAGAACTCAACAATGACCAACAACAACCACCAAATCGACAGAATACAAAAACAAAAAAAAACAACCCAAAAAAGAATCGCAAAAAAAGAAATCCAACCGGCCGAAAAGCAGCCCAGCAACACGAGAACAACCACCCCAACAGAAACCCAA...
output:
result:
wrong answer Answer contains longer sequence [length = 50000], but output contains 0 elements
Test #7:
score: 0
Wrong Answer
time: 3ms
memory: 3596kb
input:
AACAGCCGACAACAGATACAAAGGGAACAAAAGAGTCCAACAACCCAAACCACAGCACAAAATGAAAACAAACAGAAACCGAACGACTCAATCTCACAAGGATAGAGAGACGAAACGGGCGCCAACAAATACCCTACAAAAGAAAACAAAGCCTGGACGCAAAGAACACACACAAAGAGAAAAGAAAACTCACCAACAGGACAAGAAAACAAAAACACAGCACCCGGAACCAAACCATACAAGGCAACAAACAAGCACCCGCGAAAAATACGACGTCACGGAAAAACAACAGACCCCAAC...
output:
result:
wrong answer Answer contains longer sequence [length = 50000], but output contains 0 elements
Test #8:
score: 0
Wrong Answer
time: 7ms
memory: 3916kb
input:
TAAACAAAAGGCAGACAGACACACACGAGAAGAAGAACGGTCGAGAAGAAAGCGCCTACAAAACCCACAGACCCGGACACTACAAAGATACAGAAACAAGCGCGAAACAGAACAAAGAAACACAAACCCAGCCCAAAACACAGAATCAAAGGTCAGCTAAAACACGCAAGCTCAACGCAAAAACCAAACCAGTAAATCCAACAACAAATATGGAAAACCCCAGAACAGCAACAACCCTCGGAAATAGCCCATGCCGCCCTTCAAAGAAAAGAACGATAAGAAAGAGTAGCCCAATAAAGA...
output:
result:
wrong answer Answer contains longer sequence [length = 230000], but output contains 0 elements
Test #9:
score: 0
Wrong Answer
time: 3ms
memory: 3924kb
input:
ACCCACCACCGCGAGGAAAAACACAACCAAAACAACGGCGTCCACAAACGACACGCGAGACAGCACAAGAACAAAAGCCAAGACAGAACAGCTAAAAAACGACTATAACCAACAATCAACCCACACAACACAAAAAAGCCACGAGAAAAGACAACCCCAACCCAATAGACAACACCACCCACAAAAGACCGAACAAGAACAAAAGACCCAACGCAACCAAAGACCAAATGTAACCATGGAAAACATTCAGAACAGATAAAAAAATAAACAACATACAGAAGCAAGACAAACCAACCCCAT...
output:
result:
wrong answer Answer contains longer sequence [length = 230000], but output contains 0 elements
Test #10:
score: 0
Wrong Answer
time: 7ms
memory: 3876kb
input:
CGACAACAGACAAAGAAAACCAAAATTCAAACCCACGACCAAACAAAACAACACAAACGCCACCAATAACGCGCGATCACACAACCAAAACGCCAGACTAAAACCAAAATATTATAAGCACCAAAACCACGACCGAAACCGGACCCGGAAGGGAGAACCAAGCAACACTAACATACACTAAAAGCAAAACAAAGCACAAACACCAAAACAACAAACCCACAGTAGCATAAAACTAAGCACAACGGAAAGACCAAACCGACCCTCGAAGATAACCAAGCACCACCCAGGCAATCGAACCCA...
output:
result:
wrong answer Answer contains longer sequence [length = 230000], but output contains 0 elements