QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#219244 | #5666. Repetitive Elements | JenniferLing# | WA | 11ms | 3600kb | C++17 | 991b | 2023-10-19 10:05:38 | 2023-10-19 10:05:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
string s; cin >> s;
int n = (int)s.size();
string res = "";
auto chk = [&](string t, int len) {
int cnt = 0;
for (int i = 0; i < n - len; i++) {
if (s[i] == t[0]) {
int flag = 1;
for (int j = 0; j < len; j++) {
if (s[i + j] != t[j]) {
flag = 0;
break;
}
}
if (flag) {
i += len - 1;
cnt++;
}
}
}
return cnt >= 2;
};
for (int l = 0; l < n; l++) {
for (int r = l; r < n; r++) {
if (r - l + 1 > n / 2) continue;
if (chk(s.substr(l, r - l + 1), r - l + 1)) {
if (r - l + 1 > (int)res.size()) {
res = s.substr(l, r - l + 1);
}
}
}
}
cout << res << "\n";
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int T = 1;
cin >> T;
while (T--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3600kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: -100
Wrong Answer
time: 11ms
memory: 3524kb
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 GA 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:
wrong answer 22nd lines differ - expected: 'GAG', found: 'GA'