QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#102985#5666. Repetitive ElementswakakakaAC ✓16ms3428kbC++17503b2023-05-03 21:09:192023-05-03 21:09:22

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 21:09:22]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:3428kb
  • [2023-05-03 21:09:19]
  • 提交

answer

#include <iostream>

using namespace std;

int main()
{
	int all;
	cin>>all;
	while(all--)
	{
		string s,res;
		cin>>s;
		
		int len=s.size();
		bool st=false;
		for(int i=len/2;i>=1;i--)
		{
			for(int j=0;j+i-1<len;j++)
			{
				res=s.substr(j,i);
				for(int k=j+i;k+i-1<len;k++)
				{
					string t=s.substr(k,i);
					if(res==t)
					{
						st=true;
						break;
					}
				}
				if(st) break;
			}
			if(st) break;
		}
		
		cout<<res<<endl;
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
TATCGATCGAGTTGT
TCCGCGAGCGAGTCTCTCCATT
GTTTCATCATACGAGGCCCCATACGCGCTGG
AGATGGGATCCTTATG
GCCCTTAGGCATGGGATGTCGTTTCTTG

output:

ATCG
GCGA
CATACG
GAT
CTT

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 16ms
memory: 3380kb

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