QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#90905 | #5666. Repetitive Elements | He_Ren | AC ✓ | 24ms | 3568kb | C++23 | 857b | 2023-03-26 02:31:46 | 2023-03-26 02:32:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e2 + 5;
char s[MAXN];
void solve(void)
{
scanf("%s",s+1);
int n = strlen(s+1);
string ans;
auto chk = [&] (string t)
{
if(t.size() <= ans.size()) return;
int lst = 0, cnt = 0;
for(int i=1; i+(int)t.size()-1<=n; ++i)
{
bool flag = 1;
for(int j=0; j<(int)t.size(); ++j)
if(s[i+j] != t[j])
{
flag = 0;
break;
}
if(flag == 0) continue;
if(lst != 0 && lst + (int)t.size() - 1 >= i)
return;
lst = i; ++cnt;
}
if(cnt >= 2)
ans = t;
};
for(int i=1; i<=n; ++i)
for(int j=i; j<=n; ++j)
chk(string(s+i, s+j+1));
printf("%s\n",ans.c_str());
}
int main(void)
{
int T;
scanf("%d",&T);
while(T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3568kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 24ms
memory: 3536kb
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