QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#102504 | #5666. Repetitive Elements | wakakaka# | AC ✓ | 27ms | 3452kb | C++17 | 1.1kb | 2023-05-03 14:04:35 | 2023-05-03 14:04:37 |
Judging History
answer
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int ans ;
//string anss;
const int N = 110;
signed main(){
ios :: sync_with_stdio(false);
cin.tie(0) , cout.tie(0);
int T ; cin >> T ;
while( T -- ){
string s ; cin >> s ;
string anss ;
ans = 0;
for(int i=0; i<s.size(); i++){
for(int j=0; j<=s.size()-i; j++){
string subs;
for(int k=j; k<j+i; k++){
subs += s[k];
}
int res = 0 ;
for(int p=0; p<s.size();){
if(s[p] == subs[0]){
bool flag = true;
int q , cnt ;
for(q=p,cnt=0; cnt<subs.size(); cnt++,q++){
if(s[q] != subs[cnt]){
flag = false;
break;
}
}
if(flag){
p = q ;
res ++ ;
}
else{
p ++ ;
}
}
else p ++ ;
}
if(res > 1){
if(subs.size() > ans){
ans = subs.size();
anss = subs;
}
}
// if(subs.size() > ans){
// ans = subs.size();
// res =
// anss = subs;
// }
}
}
// cout << ans << ' ';
cout << anss << '\n';
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3452kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 27ms
memory: 3412kb
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