QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#102446 | #5666. Repetitive Elements | WPS# | AC ✓ | 14ms | 3504kb | C++17 | 913b | 2023-05-03 13:18:30 | 2023-05-03 13:18:31 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int maxn = 3e5+10;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f3f3f3f3f;
void solve(){
string s;
cin>>s;
int len= s.size();
map<string,int>mp;
map<string,int>mp2;
string as="";
int va=0;
for(int i=0;i<len;i++){
string ts="";
for(int j=i;j<len;++j){
ts+=s[j];
int ll=ts.size();
for(int z=j+1;z<=len-ll;z++){
if(s.substr(z,ll)==ts){
if(ll>va){
va=ll;
as=ts;
}
}
}
}
}
cout<<as<<endl;
}
int32_t main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int T=1;
cin>>T;
while(T--){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3504kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 14ms
memory: 3408kb
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