QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#95688 | #5666. Repetitive Elements | SGColin# | AC ✓ | 21ms | 1760kb | C++14 | 775b | 2023-04-11 13:27:32 | 2023-04-11 13:27:35 |
Judging History
answer
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=100;
int te,n;char s[maxn+5];
int fai[maxn+5];
int main(){
for (scanf("%d",&te);te;te--){
scanf("%s",s+1);n=strlen(s+1);
for (int len=n/2;len;len--)
for (int l=1,r=len;r<=n;l++,r++){
for (int i=l+1,j=0;i<=r;i++){
while (j && s[l+j]!=s[i]) j=fai[j];
j+=(s[l+j]==s[i]);fai[i-l+1]=j;
}
int lst=-n,cnt=0;bool fl=true;
for (int i=1,j=0;i<=n;i++){
while (j && s[l+j]!=s[i]) j=fai[j];
j+=(s[l+j]==s[i]);
if (j==len){
if (i<lst+len) {fl=false;break;}
lst=i;cnt++;j=fai[j];
}
}
if (cnt>1 && fl){
for (int i=l;i<=r;i++) putchar(s[i]);puts("");
goto OK;
}
}
OK:continue;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 1760kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 21ms
memory: 1620kb
input:
50 TTGACAACTTCAGGTTGGCACTCCTTCATTTGGATTTCGGAATAATAGTTTTCTGCTCTGCC ATCCTATTCGGGGATAGGAGAGATGGGTTGCCGCTATAAAAGCATTTGAACTCCATTTCACTCCGTTGGCTAGGGGTCGCACTG CCGTAATATAAAGACTCGGAATTCCAATAGCTGCTATTTGCGAGTATGTGACTGAAAACACACCTATAAATATTAGCTGCGTACAAGCTA ATGGCTGCATGCAGGGTCGACTAGACACACTTTGTCT TTGAGGATGTCGACGTGTCT...
output:
CTTCA CATTT TAGCTGC TGCA ACGTG GCGCCGG CTCTT AGTAT AGAG ACAG TAT TGAC CTTG CGTC TACTGG GCCGGT GAA CAGTA GCGT GGTT CCCT GAG TAGAC GGTGC GCAGT TGAG ATCAA CCACACA GAGTC ATGTA ATGGTA TATA TATGAA TTCC CATACG TACCA TTAG GGAATGT CAGG GCT AAG CTGT GGAT TCTTC AAAAC ATG GATAA TTA ACATAT CAAT
result:
ok 50 lines