QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#520608 | #5666. Repetitive Elements | ouo# | AC ✓ | 14ms | 3856kb | C++20 | 1.4kb | 2024-08-15 14:15:33 | 2024-08-15 14:15:33 |
Judging History
answer
#include <bits/stdc++.h>
#ifdef LOCAL
using std::cerr;
#else
#endif
#define F first
#define S second
#define pb push_back
#define ALL(x) begin(x), end(x)
using namespace std;
using pii = pair<int, int>;
string s;
bool check(int st, int ed, string &t) {
bool res = true;
for (int i = st, j = 0; i < ed; i++) {
if (s[i] != t[j++]) {
res = false;
break;
}
}
return res;
}
void sol() {
int len = 0, num = 0;
string ans;
for (int i = 1; i < s.size()+1; i++) {
for (int j = 0; j+i <= s.size(); j++) {
string tmp;
int cnt = 0;
for (int k = j; k < j+i; k++) {
tmp += s[k];
}
for (int k = 0; k+i <= s.size(); ) {
bool res = check(k, k+i, tmp);
if (res) {
cnt++;
k += i;
}else {
k++;
}
}
if (i > len) {
if (cnt > 1) {
ans = tmp;
len = i;
}
}
}
}
cout << ans << '\n';
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0);
int tc = 1;
cin >> tc;
while (tc--) {
cin >> s;
sol();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3796kb
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: 3856kb
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