Submission #682842

#TimeUsernameProblemLanguageResultExecution timeMemory
682842paulo_arMutating DNA (IOI21_dna)C++17
0 / 100
35 ms7368 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; int a [100002]; int t [100002]; int ap [100002]; int tp [100002]; int a0t [100002]; int a0c [100002]; int c0a [100002]; int c0t [100002]; int t0a [100002]; int t0c [100002]; void init(std::string s1, std::string s2) { for(int i=0; i<s1.size(); i++){ if(s1[i]=='a')a[i]=1; else if(s1[i]=='t')t[i]=1; if(s2[i]=='a')ap[i]=1; else if(s2[i]=='t')tp[i]=1; if(s1[i]=='a' && s2[i]=='t'){ a0t[i]=1; }if(s1[i]=='a' && s2[i]=='c'){ a0c[i]=1; }if(s1[i]=='c' && s2[i]=='t'){ c0t[i]=1; }if(s1[i]=='c' && s2[i]=='a'){ c0a[i]=1; }if(s1[i]=='t' && s2[i]=='a'){ t0a[i]=1; }if(s1[i]=='t' && s2[i]=='c'){ t0c[i]=1; } a[i]+=a[i-1]; t[i]+=t[i-1]; ap[i]+=ap[i-1]; tp[i]+=tp[i-1]; a0t[i]+=a0t[i-1]; a0c[i]+=a0c[i-1]; t0a[i]+=t0a[i-1]; t0c[i]+=t0c[i-1]; c0a[i]+=c0a[i-1]; c0t[i]+=c0t[i-1]; } } int get_distance(int x, int y) { int ans=0; int macro; if(a[y]-a[x-1]!=ap[y]-ap[x-1] || t[y]-t[x-1]!=tp[y]-tp[x-1])return -1; ans+=min(a0t[y]-a0t[x-1],t0a[y]-t0a[x-1]); macro=ans; ans+= (2*(a0t[y]-a0t[x-1]-macro)); ans+=min(c0t[y]-c0t[x-1],t0c[y]-t0c[x-1]); ans+=min(a0c[y]-a0c[x-1],c0a[y]-c0a[x-1]); return ans; }

Compilation message (stderr)

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