QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102655#5666. Repetitive Elementsnorth_h#AC ✓7ms3376kbC++14896b2023-05-03 15:32:552023-05-03 15:32:58

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 15:32:58]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:3376kb
  • [2023-05-03 15:32:55]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

using namespace std;

const int N = 30;

int a[N];
int n;
vector<string> st;

void solve() {
    string s;
    cin >> s;
    st.clear();
    for (int i = 2; i <= s.size(); i++) {
        for (int j = 0; j + i - 1 < s.size(); j++) {
            string str = s.substr(j, i);
            //cout << str << s.find(str, j + 1)<<endl;
            if (s.find(str, j + i) != s.npos)st.push_back(str);
        }
    }
    //cout << st.size() << endl;
    int ans = 0;
    string sans;
    for (auto i: st) {
        if (ans < i.size()){
            ans = i.size();
            sans=i;
        }
        //cout << i << endl;
    }
    cout<<sans<<endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h_h;
    cin>>h_h;
    cin.get();
    while(h_h--)solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3376kb

input:

5
TATCGATCGAGTTGT
TCCGCGAGCGAGTCTCTCCATT
GTTTCATCATACGAGGCCCCATACGCGCTGG
AGATGGGATCCTTATG
GCCCTTAGGCATGGGATGTCGTTTCTTG

output:

ATCG
GCGA
CATACG
GAT
CTT

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 7ms
memory: 3344kb

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