Submission #675612

#TimeUsernameProblemLanguageResultExecution timeMemory
67561212332100Mutating DNA (IOI21_dna)C++17
35 / 100
34 ms6612 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; string s,ss; int dna[2][3][100001],jem[100001]; map<char,int>mp; void init(string s,string ss) { mp['A']=0; mp['T']=1; mp['C']=2; dna[0][mp[s[0]]][0]=1; dna[1][mp[ss[0]]][0]=1; for(int i=1;i<s.size();i++){ if(s[i]==ss[i])jem[i]=jem[i-1]+1; else jem[i]=jem[i-1]; // for(int j=0;j<3;j++){ dna[0][j][i]=dna[0][j][i-1]; dna[1][j][i]=dna[1][j][i-1]; } dna[0][mp[s[i]]][i]++; dna[1][mp[ss[i]]][i]++; } } int get_distance(int x, int y) { int ans,a1,a2,t1,t2; if(x>0){ ans=jem[y]-jem[x-1]; a1=dna[0][0][y]-dna[0][0][x-1]; a2=dna[1][0][y]-dna[1][0][x-1]; t1=dna[0][1][y]-dna[0][1][x-1]; t2=dna[1][1][y]-dna[1][1][x-1]; } else{ ans=jem[y]; a1=dna[0][0][y]; a2=dna[1][0][y]; t1=dna[0][1][y]; t2=dna[1][1][y]; } if(a1!=a2 || t1!=t2)return -1; return ((y-x+1)-ans)/2; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i=1;i<s.size();i++){
      |              ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...