Submission #979825

#TimeUsernameProblemLanguageResultExecution timeMemory
979825batsukh2006Mutating DNA (IOI21_dna)C++17
0 / 100
29 ms8208 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; const int mxN=1e5+1; int mp[mxN][3][3]; int f[mxN][3],s[mxN][3]; void init(string a, string b){ map<char,int> m; m['A']=0; m['T']=1; m['C']=2; for(int i=1; i<=a.size(); i++){ for(int j=0; j<3; j++){ f[i][j]=f[i-1][j]; s[i][j]=s[i-1][j]; for(int k=0; k<3; k++){ mp[i][j][k]=mp[i-1][j][k]; } } f[i][m[a[i-1]]]++; s[i][m[b[i-1]]]++; mp[i][m[a[i-1]]][m[b[i-1]]]++; } } int get_distance(int x, int y){ for(int i=0; i<3; i++){ if(f[y+1][i]-f[x][i]!=s[y+1][i]-s[x][i]){ return -1; } } int ans=y-x+1; for(int i=0; i<3; i++){ for(int j=i; j<3; j++){ ans-=min(mp[y+1][i][j]-mp[x][i][j],mp[y+1][j][i]-mp[x][j][i]); } } return max(ans-1,1); }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:12:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i=1; i<=a.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...