QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#238820 | #5666. Repetitive Elements | ItsJerr# | AC ✓ | 3ms | 4248kb | C++17 | 1.1kb | 2023-11-04 17:38:32 | 2023-11-04 17:38:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 110;
string s[N][N]; int n;
int cnt(int l, int r) {
for (int i = 2 * r - l + 1; i <= n; ++i) if (s[i - r + l][i] == s[l][r]) return 2;
return 1;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("qoj_5666.inp", "r")) {
freopen("qoj_5666.inp", "r", stdin);
freopen("qoj_5666.out", "w", stdout);
}
#ifdef LOCAL_MACHINE
if (fopen("task.inp", "r")) {
freopen("task.inp", "r", stdin);
freopen("task.out", "w", stdout);
}
#endif
int nTest; cin >> nTest;
while(nTest--) {
string st; cin >> st;
n = st.size(); st = ' ' + st;
for (int i = 1; i <= n; ++i) {
s[i][i] = st[i];
for (int j = i + 1; j <= n; ++j) s[i][j] = s[i][j - 1] + st[j];
}
string res = "";
for (int len = n; len; --len) for (int l = 1; l <= n - len + 1; ++l) if (res.size() == 0 && cnt(l, l + len - 1) > 1) res = s[l][l + len - 1];
cout << res << "\n";
}
}
// ඞඞඞඞඞ you sus
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3864kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 3ms
memory: 4248kb
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