QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#219517 | #5666. Repetitive Elements | shen0628# | WA | 1ms | 3660kb | C++17 | 692b | 2023-10-19 15:53:32 | 2023-10-19 15:53:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii; // (cnt,start_pos)
typedef long double ld;
typedef long long ll;
string s;
unordered_map<string,pii> mp;
void solve(){
mp.clear();
cin>>s;
int k=s.size()-1;
for(int i=k;i>=1;i--){//100
for(int j=0;j+i<s.size();j++){//100
string tmp=s.substr(j,i);//100
if(mp.count(tmp)&&mp[tmp].second+i-1<j){//map -> O(log100) unordered_map->O(1)
cout<<tmp<<"\n";
return;
}else{
mp[tmp]={1,j};
}
}
}
}
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tt=1; cin >> tt;
while(tt--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3660kb
input:
5 TATCGATCGAGTTGT TCCGCGAGCGAGTCTCTCCATT GTTTCATCATACGAGGCCCCATACGCGCTGG AGATGGGATCCTTATG GCCCTTAGGCATGGGATGTCGTTTCTTG
output:
ATCG GCGA CATACG GAT ATG
result:
wrong answer 5th lines differ - expected: 'CTT', found: 'ATG'