QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#278842 | #5666. Repetitive Elements | dat# | AC ✓ | 1ms | 3552kb | C++17 | 1.5kb | 2023-12-07 21:18:09 | 2023-12-07 21:18:10 |
Judging History
answer
#ifdef LOCAL
#include "precompiled_headers.h"
#else
#include <bits/stdc++.h>
#endif
using namespace std;
string mul_k(string s, int k) {
string res;
for (int i=1; i<=k; i++) {
res += s;
}
return res;
}
int main() {
std::ios::sync_with_stdio(0);
cin.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n;
cin >> n;
for (int i=1; i<=n; i++) {
string s;
cin >> s;
int max_val = 0;
int max_start, max_len;
for (int i=0; i<s.length(); i++) {
for (int j=0; j<s.length(); j++) {
if (i != j && s[i] == s[j]) {
int start_i = i;
int start_j = j;
int curr_i = start_i;
int curr_j = start_j;
while (curr_i < start_j && curr_i < s.length() && curr_j < s.length() && s[curr_i] == s[curr_j]) {
curr_i++;
curr_j++;
}
if (curr_i - start_i > max_val) {
max_val = curr_i - start_i;
max_start = start_i;
max_len = max_val;
}
}
}
}
string ss;
for (int i=0; i<max_val; i++) {
ss += s[max_start + i];
}
cout << ss << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3552kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 3548kb
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