QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102446#5666. Repetitive ElementsWPS#AC ✓14ms3504kbC++17913b2023-05-03 13:18:302023-05-03 13:18:31

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 13:18:31]
  • 评测
  • 测评结果:AC
  • 用时:14ms
  • 内存:3504kb
  • [2023-05-03 13:18:30]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int maxn = 3e5+10;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f3f3f3f3f;
void solve(){
    string s;
    cin>>s;
    int len= s.size();
    map<string,int>mp;
    map<string,int>mp2;
    string as="";
    int va=0;
    for(int i=0;i<len;i++){
        string ts="";
        for(int j=i;j<len;++j){
            ts+=s[j];
            int ll=ts.size();
            for(int z=j+1;z<=len-ll;z++){
                if(s.substr(z,ll)==ts){
                    if(ll>va){
                        va=ll;
                        as=ts;
                    }
                }
            }
        }
    }
   cout<<as<<endl;
}

int32_t main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int T=1;
    cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


詳細信息

Test #1:

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

input:

5
TATCGATCGAGTTGT
TCCGCGAGCGAGTCTCTCCATT
GTTTCATCATACGAGGCCCCATACGCGCTGG
AGATGGGATCCTTATG
GCCCTTAGGCATGGGATGTCGTTTCTTG

output:

ATCG
GCGA
CATACG
GAT
CTT

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 14ms
memory: 3408kb

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