QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#102480 | #5666. Repetitive Elements | ir101# | AC ✓ | 21ms | 3472kb | C++17 | 1.3kb | 2023-05-03 13:48:03 | 2023-05-03 13:48:07 |
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){
int l=-1;
for(int j=0;j+i-1<s.size();++j){
string a=s.substr(j,i);
int g=0;
int f=-1;
string s1=s;
while(s1.find(a)!=-1){
g++;
s1=s1.substr(s1.find(a)+a.size(),s1.size()-a.size());
}
if(g>=2){
ok= true;
res=a;
break;
}
}
if(ok)break;
}
cout<<res<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3460kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT CTT
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 21ms
memory: 3472kb
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