QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#183616 | #5666. Repetitive Elements | real_sigma_team# | WA | 1ms | 3616kb | C++20 | 936b | 2023-09-19 18:21:17 | 2023-09-19 18:21:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using ll = long long;
void solve() {
string s;
cin >> s;
int n = s.size();
for (int len = n; len > 0; --len) {
map<string, int> last, cnt, ok;
for (int i = 0; i + len - 1 < n; ++i) {
string t(s.begin() + i, s.begin() + i + len);
if (last.count(t) && last[t] + len - 1 >= i) ok[t] = 1;
cnt[t]++;
last[t] = i;
}
for (auto [t, x] : cnt) {
if (x < 2) continue;
if (ok[t]) continue;
cout << t << '\n';
return;
}
}
}
int main() {
#ifndef LOCAL
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#else
freopen("input.txt", "r", stdin);
#endif
int t;
cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3616kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG CGAG CATACG ATG ATG
result:
wrong answer 2nd lines differ - expected: 'GCGA', found: 'CGAG'