QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#102504#5666. Repetitive Elementswakakaka#AC ✓27ms3452kbC++171.1kb2023-05-03 14:04:352023-05-03 14:04:37

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 14:04:37]
  • 评测
  • 测评结果:AC
  • 用时:27ms
  • 内存:3452kb
  • [2023-05-03 14:04:35]
  • 提交

answer

#include<iostream>
#include<map>
#include<algorithm>

using namespace std;

int ans ;
//string anss;

const int N = 110;

signed main(){
	ios :: sync_with_stdio(false);
	cin.tie(0) , cout.tie(0);
	
	int T ; cin >> T ;
	
	while( T -- ){
		string s ; cin >> s ;
		string anss ;
		ans = 0;
		for(int i=0; i<s.size(); i++){
			for(int j=0; j<=s.size()-i; j++){
				string subs;
				for(int k=j; k<j+i; k++){
					subs += s[k];
				}
				int res = 0 ;
				for(int p=0; p<s.size();){
					if(s[p] == subs[0]){
						bool flag = true;
						int q , cnt ;
						for(q=p,cnt=0; cnt<subs.size(); cnt++,q++){
							if(s[q] != subs[cnt]){
								flag = false;
								break;
							}
						}
						if(flag){
							p = q ;
							res ++ ;
						}
						else{
							p ++ ;
						}
					}
					else p  ++ ;
				}
				if(res > 1){
					if(subs.size() > ans){
						ans = subs.size();
						anss = subs;
					}
				}
//				if(subs.size() > ans){
//					ans = subs.size();
//					res = 
//					anss = subs;
//				}
			}
		}
		
	//	cout << ans << ' ';
		
		cout << anss << '\n';
	}
	
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
TATCGATCGAGTTGT
TCCGCGAGCGAGTCTCTCCATT
GTTTCATCATACGAGGCCCCATACGCGCTGG
AGATGGGATCCTTATG
GCCCTTAGGCATGGGATGTCGTTTCTTG

output:

ATCG
GCGA
CATACG
GAT
CTT

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 27ms
memory: 3412kb

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