QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#204168#5666. Repetitive ElementsAlfehAC ✓11ms3500kbC++14873b2023-10-07 04:46:242023-10-07 04:46:26

Judging History

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

  • [2023-10-07 04:46:26]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:3500kb
  • [2023-10-07 04:46:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
const int sz = 1e5 + 5, mod = 1e9 + 7;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t; cin >> t;
    while(t--) {
        string s; cin >> s;
        int n = s.size();
        for(int len = n; len >= 1; len--) {
            int paisi = 0;
            for(int i = 0; i + len <= n && !paisi; i++) {
                string c = s.substr(i, len);
                int paisi1 = 0;
                for(int j = i + len; j + len <= n && !paisi1; j++) {
                    if(s.substr(j, len) == c)
                        paisi1 = 1;
                }
                if(paisi1) {
                    cout << c << "\n";
                }
                paisi|=paisi1;
            }
            if(paisi) break;
        }
    }
    return 0; 
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3500kb

input:

5
TATCGATCGAGTTGT
TCCGCGAGCGAGTCTCTCCATT
GTTTCATCATACGAGGCCCCATACGCGCTGG
AGATGGGATCCTTATG
GCCCTTAGGCATGGGATGTCGTTTCTTG

output:

ATCG
GCGA
CATACG
GAT
CTT

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 11ms
memory: 3480kb

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