Submission #1001629

#TimeUsernameProblemLanguageResultExecution timeMemory
1001629ayankarimovaMutating DNA (IOI21_dna)C++17
100 / 100
42 ms8712 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; #define ll long long const ll sz= 100000+5; ll p[sz][6]; void init(std::string a, std::string b) { for(int i=0; i<a.size(); i++){ for(int j=0; j<6; j++) p[i][j]+=p[i-1][j]; if(a[i]=='A' && b[i]=='C') p[i][0]++; if(a[i]=='A' && b[i]=='T') p[i][1]++; if(a[i]=='C' && b[i]=='A') p[i][2]++; if(a[i]=='C' && b[i]=='T') p[i][3]++; if(a[i]=='T' && b[i]=='A') p[i][4]++; if(a[i]=='T' && b[i]=='C') p[i][5]++; } } int get_distance(int x, int y) { ll ac=p[y][0]-p[x-1][0]; ll att=p[y][1]-p[x-1][1]; ll ca=p[y][2]-p[x-1][2]; ll ct=p[y][3]-p[x-1][3]; ll ta=p[y][4]-p[x-1][4]; ll tc=p[y][5]-p[x-1][5]; if(ac+att==ca+ta && ca+ct==ac+tc && ta+tc==att+ct){ ll a=min(ac, ca); ll b=min(tc, ct); ll c=min(ta, att); ll res=ac+ca-2*a + tc+ct-2*b + att+ta - 2*c; return a+b+c+res*2/3; } return -1; } /* {} [] */

Compilation message (stderr)

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