QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#261699 | #5666. Repetitive Elements | haze | AC ✓ | 1ms | 3712kb | C++14 | 903b | 2023-11-23 08:53:33 | 2023-11-23 08:53:35 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define irep(i, l, r) for(int i = (l); i <= (r); ++ i)
#define drep(i, r, l) for(int i = (r); i >= (l); -- i)
const int N = 500009;
const int mod = 1000000000 + 7;
inline ll read(){
ll s = 0;
bool w = 0;
char ch = getchar();
while(!isdigit(ch)){
if(ch == '-')w = 1;
ch = getchar();
}
while(isdigit(ch)){
s *= 10, s += ch ^ 48;
ch = getchar();
}
return w ? -s : s;
}
void solve(){
string s;
cin >> s;
int n = s.length();
int l0 = 0, r0 = 0;
for(int i = 0; i < n; ++ i){
for(int j = i + 1; j < n; ++ j){
int x = i, y = j;
while(x < j && y < n && s[x] == s[y])
++ x, ++ y;
if(r0 - l0 < y - j){
r0 = y, l0 = j;
}
}
}
for(int i = l0; i < r0; ++ i){
putchar(s[i]);
}
putchar('\n');
}
int main(){
int T = read();
while(T --){
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 3712kb
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