QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#183616#5666. Repetitive Elementsreal_sigma_team#WA 1ms3616kbC++20936b2023-09-19 18:21:172023-09-19 18:21:17

Judging History

你现在查看的是最新测评结果

  • [2023-09-19 18:21:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3616kb
  • [2023-09-19 18:21:17]
  • 提交

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'