QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#114307 | #5666. Repetitive Elements | yzkkai# | AC ✓ | 2ms | 3460kb | C++17 | 885b | 2023-06-21 22:51:20 | 2023-06-21 22:51:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pt = pair<int, int>;
using vi = vector<int>;
#define sz(x) (int)size(x)
#define all(x) begin(x), end(x)
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lowbit(x) (x) & (-x)
const int mod = 1e9 + 7;
inline void solve() {
string s;
cin >> s;
int n = sz(s);
string ans = "";
for (int i = 0; i < n; ++i)
for (int j = i + 1; j < n; ++j) {
string tmp = "";
for (int k = 0; i + k < j && max(i, j) + k < n; ++k) {
if (s[i + k] != s[j + k]) break;
tmp += s[i + k];
}
if (sz(ans) < sz(tmp))
ans = tmp;
}
cout << ans << endl;
return;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3428kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 2ms
memory: 3460kb
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