QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#102482 | #5666. Repetitive Elements | ir101# | AC ✓ | 32ms | 3464kb | C++17 | 1.3kb | 2023-05-03 13:49:07 | 2023-05-03 13:49:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>PII;
typedef pair<string,int>PSI;
const int N=2e5+5,INF=0x3f3f3f3f,Mod=1e6;
const double eps=1e-6;
typedef long long ll;
int chaxun(string s,string sub){
int idx = 0; //开始查找的下标 & 找到子串的首字母下标
int cnt = 0; //子串出现次数
//s.find(sub, idx)从s的idx处开始查找sub
while ((idx = s.find(sub, idx)) != s.npos){
idx++;
cnt++;
}
return cnt;
}
int t;
string s;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>t;
while(t--){
cin>>s;
bool ok=false;
string res;
//unordered_map<string,int>mp;
for(int i=s.size()-1;i>=1;--i){
for(int j=0;j+i-1<s.size();++j){
string a=s.substr(j,i);
for(int k=0;k+i-1<s.size();++k){
if((k<j&&k+i-1>=j)||(k+i-1>j&&k<=j+i-1))continue;
string b=s.substr(k,i);
if(b==a){
ok=true;res=a;break;
}
}
if(ok)break;
}
if(ok)break;
}
cout<<res<<'\n';
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3400kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 32ms
memory: 3464kb
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