QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#113643 | #5666. Repetitive Elements | UFRJ# | AC ✓ | 5ms | 3444kb | C++20 | 829b | 2023-06-19 01:57:57 | 2023-06-19 01:57:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n;
bool match(int b, int e, int cur, const string & s){
int i, j;
for(i = cur, j = b; i < n && j < e; i++, j++){
if(s[i] != s[j])
return false;
}
if(j < e) return false;
return true;
}
void solve(){
string s; cin>>s;
n = int(s.size());
string answer = "";
for(int sz = n/2; sz >= 1; sz--){
for(int b = 0; b + sz <= n; b++){
for(int i = b + sz; i < n; i++)
if(match(b, b + sz, i, s)){
cout<<s.substr(b, sz)<<"\n";
return;
}
}
}
cout<<answer<<"\n";
}
int main(){
cin.tie(0)->sync_with_stdio(false);
int t; cin>>t;
while(t--){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3440kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 5ms
memory: 3444kb
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