QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#31796#21644. 基因序列问题LFCode10 86ms70632kbC++141.4kb2022-05-12 17:06:452022-05-12 17:06:49

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-12 17:06:49]
  • 评测
  • 测评结果:10
  • 用时:86ms
  • 内存:70632kb
  • [2022-05-12 17:06:45]
  • 提交

answer

//什么时候我才能有杜爷一半强呀/kk
//烂烂 摆摆 呜呜
#include<cstdio>
#include<iostream>
#include<cstring>
#include<unordered_map>
using std::cin;
using std::cout;
using std::unordered_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 read(){
	char ch=getchar();int nn=0,ssss=1;
	while(ch<'0'||ch>'9'){if(ch=='-')ssss*=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){nn=nn*10+(ch-'0');ch=getchar();}
	return nn*ssss;
}
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++){
		unordered_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=read();int r=read();
		cout<<s[l][r]<<'\n';
	}
	return 0;
}
}
int main(){
	cin>>(ch+1);n=strlen(ch+1);
	if(n<=5000)return sub1::mian();
}

詳細信息

Test #1:

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

input:

CCAAAACAAACACAGAGGAAACAACAACCAGCATAAACACTCAGTAAAACACGAGCACAGGAAAAAGAGAACCAGCCTCCAAAAAACAAACGCAGCACAAACTGCACCAACCGAAACAACACAACCGAAAATCCCAGTCAGGCAAGACACCAAACACGACAAACCAACACAAAAACCTACCAACACACACCAAAAACACAAAGGCTGAAAAACGACCGACCCCGCACGACAACAACAACCAAGAGACGAACCAACAACTAAACACCCAGCACGAACAAAAAACACAAGACCCCAGAAAAA...

output:


result:

wrong answer Answer contains longer sequence [length = 6500], but output contains 0 elements

Test #2:

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

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: 3500kb

input:

AAACAAGCCAACAAGGACGCCAAAAGCACGCAATACAAGACCACCTGACAAACGAAAACTAACCAAACAGCACGAAAACAGACAAGGAACACAAGGAGAACAAGAAGATAACAAAAACTAGAAAAAAACACCATAACAGCATGCAAAACACAAACCCAAAACAAAAACTTAACAAAAAAAAGACAAGGGCCCACAAAAACAACAAAAAAAACCTCCTGAACAACCGCGGACAACCCGACCCACGCGCGCCCGGACCAACCAAACAAACTAAACCAGAACCCCCCCCGCGCAAAACCAACA...

output:


result:

wrong answer Answer contains longer sequence [length = 23000], but output contains 0 elements

Test #4:

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

input:

AAAAAAACCACACACGAAGCAACGACACATCCAAACGAAAAAAAACAGAAAAGATTAACTCAAAACCAAAAACAAACCAGAGAAGGGGACAGGTAACCGAAATTAAACCCCTGCAACCCAAGCAAAAAAAACCCATACACCCCAGAAGCAAACAAACAGAGAAAGACAACCAGGCGAACTAAAAGAAAAAAACACAACCGGATCAGAACCACACTAAAGCCACCATCAACCGGCCGCGCAAACAAAGCAGCAACAACCACAATAACCATAACAAAAGAAGTAAATACCGCGGCAACAAAA...

output:


result:

wrong answer Answer contains longer sequence [length = 23000], but output contains 0 elements

Test #5:

score: 10
Accepted
time: 86ms
memory: 70632kb

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:

ok 230000 numbers

Test #6:

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

input:

GCAGAACAGGGAAATGCACCCGCCCCCACAACCACCACACACCAGAACTAAGTCTAAACTGGAGAATACAAAACCCCGAAACAATGCGTCCAACAAGCAGCAAAACGTATACGACAACCAAACACACAAACAGAGCCACAACTAAAAACGCAGAACTCAACAATGACCAACAACAACCACCAAATCGACAGAATACAAAAACAAAAAAAAACAACCCAAAAAAGAATCGCAAAAAAAGAAATCCAACCGGCCGAAAAGCAGCCCAGCAACACGAGAACAACCACCCCAACAGAAACCCAA...

output:


result:

wrong answer Answer contains longer sequence [length = 50000], but output contains 0 elements

Test #7:

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

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: 3860kb

input:

TAAACAAAAGGCAGACAGACACACACGAGAAGAAGAACGGTCGAGAAGAAAGCGCCTACAAAACCCACAGACCCGGACACTACAAAGATACAGAAACAAGCGCGAAACAGAACAAAGAAACACAAACCCAGCCCAAAACACAGAATCAAAGGTCAGCTAAAACACGCAAGCTCAACGCAAAAACCAAACCAGTAAATCCAACAACAAATATGGAAAACCCCAGAACAGCAACAACCCTCGGAAATAGCCCATGCCGCCCTTCAAAGAAAAGAACGATAAGAAAGAGTAGCCCAATAAAGA...

output:


result:

wrong answer Answer contains longer sequence [length = 230000], but output contains 0 elements

Test #9:

score: 0
Wrong Answer
time: 7ms
memory: 3748kb

input:

ACCCACCACCGCGAGGAAAAACACAACCAAAACAACGGCGTCCACAAACGACACGCGAGACAGCACAAGAACAAAAGCCAAGACAGAACAGCTAAAAAACGACTATAACCAACAATCAACCCACACAACACAAAAAAGCCACGAGAAAAGACAACCCCAACCCAATAGACAACACCACCCACAAAAGACCGAACAAGAACAAAAGACCCAACGCAACCAAAGACCAAATGTAACCATGGAAAACATTCAGAACAGATAAAAAAATAAACAACATACAGAAGCAAGACAAACCAACCCCAT...

output:


result:

wrong answer Answer contains longer sequence [length = 230000], but output contains 0 elements

Test #10:

score: 0
Wrong Answer
time: 8ms
memory: 5876kb

input:

CGACAACAGACAAAGAAAACCAAAATTCAAACCCACGACCAAACAAAACAACACAAACGCCACCAATAACGCGCGATCACACAACCAAAACGCCAGACTAAAACCAAAATATTATAAGCACCAAAACCACGACCGAAACCGGACCCGGAAGGGAGAACCAAGCAACACTAACATACACTAAAAGCAAAACAAAGCACAAACACCAAAACAACAAACCCACAGTAGCATAAAACTAAGCACAACGGAAAGACCAAACCGACCCTCGAAGATAACCAAGCACCACCCAGGCAATCGAACCCA...

output:


result:

wrong answer Answer contains longer sequence [length = 230000], but output contains 0 elements