QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102459#5666. Repetitive Elementsflashtomato#AC ✓3ms3436kbC++141.1kb2023-05-03 13:32:222023-05-03 13:32:24

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:32:24]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3436kb
  • [2023-05-03 13:32:22]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;



typedef long long ll;
const int N=1e6+10;

ll t;
string str;


    int main (void)
    {
        cin>>t;
        while (t--)
        {
            cin>>str;
            ll Len=str.size();
            ll Ans_Len=Len/2;
            for(ll i=Ans_Len;i>=1;i--)// 这个是长度
            {
                // 枚举一下开头
                bool success=false;
                for(ll j=0;j<=(Len-i);j++)
                {
                    string Ans_Str=str.substr(j,i);
                    string Find_Ans_str=str.substr(j+i);
                    ll idx=Find_Ans_str.find(Ans_Str);
                 //  cout<<Ans_Str<<" "<<Find_Ans_str<<" "<<i<<" "<<idx<<endl;
                    if(idx!=string::npos)
                    {
                        cout<<Ans_Str<<endl;
                        success= true;
                        break;
                    }
                }
                if(success)
                    break;
            }
        }
        return 0;
    }

详细

Test #1:

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

input:

5
TATCGATCGAGTTGT
TCCGCGAGCGAGTCTCTCCATT
GTTTCATCATACGAGGCCCCATACGCGCTGG
AGATGGGATCCTTATG
GCCCTTAGGCATGGGATGTCGTTTCTTG

output:

ATCG
GCGA
CATACG
GAT
CTT

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 3ms
memory: 3436kb

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