QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#182837 | #5666. Repetitive Elements | bonginn | AC ✓ | 977ms | 21064kb | C++14 | 1.4kb | 2023-09-18 16:43:25 | 2023-09-18 16:43:25 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define IOS cin.tie(0);ios_base::sync_with_stdio(false);
#define INF 1e15+9
using namespace std;
const int maxn = 2e5+5;
typedef pair<int,int> P;
void solve(){
string s;
cin >> s;
map <string,bool> mp[s.size() + 5];
string ans ;
int mx = 0;
int le = 0;
for(int i=0;i<s.size();i++){
string now = "";
for(int j=i;j>=0;j--){
now = s[j] + now;
for(int k=j-1;k>=0;k--){
if(mp[k][now]){
if(now.size() >= mx){
if(now.size() == mx){
if(k - now.size() + 1 < le){
mx = now.size();
ans = now;
le = k - now.size() + 1;
}
}
else{
mx = now.size();
ans = now;
le = k - now.size() + 1;
}
}
}
}
mp[i][now] = true;
}
}
cout << ans << '\n';
}
signed main(){IOS
int T;
cin >> T;
while(T--){
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 4148kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 977ms
memory: 21064kb
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