QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#219517#5666. Repetitive Elementsshen0628#WA 1ms3660kbC++17692b2023-10-19 15:53:322023-10-19 15:53:34

Judging History

你现在查看的是最新测评结果

  • [2023-10-19 15:53:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3660kb
  • [2023-10-19 15:53:32]
  • 提交

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'