QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#553484#5666. Repetitive Elementsfr1tz#WA 7ms3840kbC++17842b2024-09-08 14:03:502024-09-08 14:03:58

Judging History

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

  • [2024-09-08 14:03:58]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3840kb
  • [2024-09-08 14:03:50]
  • 提交

answer

// REPETITIVE ELEMENTS

#include <bits/stdc++.h>
using namespace std;

#define ull unsigned long long
#define ll long long
#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define pp pair<int, int>
#define el '\n'

int main() {
  int t;
  string s;
  cin >> t;
  while (t--) {
    cin >> s;
    bool found = false;
    for (int length = s.size()/2; length >= 1; length--) {
      for (int i = 0; i < s.size()-length; i++) {
        string s1 = s.substr(i, length);
        for (int j = i+length; j < s.size()-length; j++) {
          string s2 = s.substr(j, length);
          if (s1 == s2) {
            cout << s1 << el;
            found = true;
            break;
          }
        }
        if (found) break;
      }
      if (found) break;
    }
  }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

input:

5
TATCGATCGAGTTGT
TCCGCGAGCGAGTCTCTCCATT
GTTTCATCATACGAGGCCCCATACGCGCTGG
AGATGGGATCCTTATG
GCCCTTAGGCATGGGATGTCGTTTCTTG

output:

ATCG
GCGA
CATACG
GAT
CTT

result:

ok 5 lines

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 3840kb

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'