QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#183939 | #5666. Repetitive Elements | MaGnsi0# | AC ✓ | 8ms | 3616kb | C++17 | 891b | 2023-09-20 01:24:26 | 2023-09-20 01:24:26 |
Judging History
answer
/**
* author: MaGnsi0
* created: 19.09.2023 20:18:33
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T;
cin >> T;
while (T--) {
string s;
cin >> s;
int n = (int)s.size();
string ans = "";
for (int l = n / 2; l >= 1; --l) {
map<string, vector<int>> mp;
for (int i = 0; i + l - 1 < n; ++i) {
mp[s.substr(i, l)].push_back(i);
}
int min_i = n;
for (auto [t, a] : mp) {
if ((int)a.size() < 2) { continue; }
if (a[0] + l - 1 >= a.back()) { continue; }
if (a[0] < min_i) { ans = t, min_i = a[0]; }
}
if (!ans.empty()) { break; }
}
cout << ans << "\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3616kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 8ms
memory: 3580kb
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