QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#88837 | #5666. Repetitive Elements | PHarr | AC ✓ | 2ms | 3332kb | C++17 | 797b | 2023-03-17 18:16:44 | 2023-03-17 18:16:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
void solve(){
string s;
cin >> s;
int n = s.size();
auto check = [=]( int len ){
string k;
for( int i = 0 ; i + len - 1 < n ; i ++ ){
k = s.substr( i , len );
for( int j = i+len ; j + len - 1 < n ; j ++ ){
if( k == s.substr( j , len ) ) return k;
}
}
k = "-1";
return k;
};
int l = 1 , r = n , mid;
string t , res;
while( l <= r ){
mid = ( l + r ) >> 1;
t = check(mid);
if( t == "-1" ) r = mid - 1;
else res = t , l = mid + 1;
}
cout << res << "\n";
}
int32_t main(){
int t ; cin >> t;
while( t --> 0 ) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3328kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 2ms
memory: 3332kb
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