QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#114307#5666. Repetitive Elementsyzkkai#AC ✓2ms3460kbC++17885b2023-06-21 22:51:202023-06-21 22:51:23

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-21 22:51:23]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3460kb
  • [2023-06-21 22:51:20]
  • 提交

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;
}

詳細信息

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