QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#732098 | #5666. Repetitive Elements | mc020207 | AC ✓ | 1ms | 3704kb | C++17 | 739b | 2024-11-10 13:12:28 | 2024-11-10 13:12:32 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define MAXN 1000010
#define INF 1000000010
#define INFLL (1LL*INF*INF)
#define MOD 998244353
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Rof(i,a,b) for (int i=(a);i>=(b);i--)
using namespace std;
int n;
string s;
void Main(){
cin>>s;n=s.size();
int len=0,p=n+1;
For(i,0,n-1) For(j,i+1,n-1){
int k;
for (k=0;j+k<n&&s[i+k]==s[j+k];k++);
if (len==min(k,j-i)) p=min(p,i);
else if (min(k,j-i)>len) len=min(k,j-i),p=i;
}
For(i,0,len-1) cout<<s[p+i];
cout<<"\n";
}
int main(){
std::ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int T=1;cin>>T;
while (T--) Main();
}
/*
3 2
1 2 3
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3704kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 3644kb
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