QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#105238 | #5666. Repetitive Elements | Sorting# | AC ✓ | 3ms | 3512kb | C++20 | 1.2kb | 2023-05-13 19:13:15 | 2023-05-13 19:13:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair < int , int > pii ;
typedef vector < int > vi ;
#define fi first
#define se second
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n ;
string a ;
bool eq ( int i , int j , int len ) {
for ( int k = 0 ; k < len ; ++ k ) {
if ( a[ i + k ] != a[ j + k ] ) { return false ; }
}
return true ;
}
int f ( int len ) {
for ( int i = 0 ; i + len - 1 < n ; ++ i ) {
for ( int j = i + len ; j + len - 1 < n ; ++ j ) {
if ( eq ( i , j , len ) == true ) { return i ; }
}
}
return -1 ;
}
void solve ( ) {
cin >> a ;
n = a.size ( ) ;
int l , r , mid ;
l = 1 , r = n / 2 ;
while ( l < r ) {
mid = ( l + r + 1 ) / 2 ;
int ret = f ( mid ) ;
if ( ret == -1 ) { r = mid - 1 ; }
else { l = mid ; }
}
int pos = f ( l ) ;
for ( int i = 0 ; i < l ; ++ i ) {
cout << a[ pos + i ] ;
}
cout << "\n" ;
}
int main ( ) {
ios_base :: sync_with_stdio ( false ) ;
cin.tie ( NULL ) ;
int t = 1 ; cin >> t ;
while ( t -- ) { solve ( ) ; }
return 0 ;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3416kb
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: 3512kb
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