Submission #437947

#TimeUsernameProblemLanguageResultExecution timeMemory
437947HaidaraMutating DNA (IOI21_dna)C++17
100 / 100
58 ms4872 KiB
#include<bits/stdc++.h> using namespace std; const int maxn=100100; int At[maxn],ta[maxn],tc[maxn],ct[maxn],ac[maxn],ca[maxn]; void init(string a, string b) { for(int i=0;i<a.size();i++) { At[i+1]=At[i]; ta[i+1]=ta[i]; tc[i+1]=tc[i]; ct[i+1]=ct[i]; ac[i+1]=ac[i]; ca[i+1]=ca[i]; if(a[i]=='A') { if(b[i]=='T') At[i+1]++; else if(b[i]=='C') ac[i+1]++; } else if(a[i]=='T') { if(b[i]=='A') ta[i+1]++; else if(b[i]=='C') tc[i+1]++; } else if(a[i]=='C') { if(b[i]=='A') ca[i+1]++; else if(b[i]=='T') ct[i+1]++; } } return ; } int get_distance(int x, int y) { y++; if((ta[y]-ta[x]+tc[y]-tc[x]!=At[y]-At[x]+ct[y]-ct[x])||(At[y]-At[x]+ac[y]-ac[x]!=ta[y]-ta[x]+ca[y]-ca[x])||(ca[y]-ca[x]+ct[y]-ct[x]!=tc[y]-tc[x]+ac[y]-ac[x])) return -1; return min(At[y]-At[x],ta[y]-ta[x])+min(tc[y]-tc[x],ct[y]-ct[x])+min(ac[y]-ac[x],ca[y]-ca[x]) +(abs(At[y]-At[x]-ta[y]+ta[x])+abs(tc[y]-tc[x]-ct[y]+ct[x])+abs(ac[y]-ac[x]-ca[y]+ca[x]))*2/3; }

Compilation message (stderr)

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