QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#102655 | #5666. Repetitive Elements | north_h# | AC ✓ | 7ms | 3376kb | C++14 | 896b | 2023-05-03 15:32:55 | 2023-05-03 15:32:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using namespace std;
const int N = 30;
int a[N];
int n;
vector<string> st;
void solve() {
string s;
cin >> s;
st.clear();
for (int i = 2; i <= s.size(); i++) {
for (int j = 0; j + i - 1 < s.size(); j++) {
string str = s.substr(j, i);
//cout << str << s.find(str, j + 1)<<endl;
if (s.find(str, j + i) != s.npos)st.push_back(str);
}
}
//cout << st.size() << endl;
int ans = 0;
string sans;
for (auto i: st) {
if (ans < i.size()){
ans = i.size();
sans=i;
}
//cout << i << endl;
}
cout<<sans<<endl;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int h_h;
cin>>h_h;
cin.get();
while(h_h--)solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3376kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 7ms
memory: 3344kb
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