Submission #438028

#TimeUsernameProblemLanguageResultExecution timeMemory
438028PiejanVDCMutating DNA (IOI21_dna)C++17
100 / 100
79 ms8272 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; string s,t; vector<vector<int>>v(100005,vector<int>(6,0)); void gen(void) { v[0]={0,0,0,0,0,0}; for(int i = 0 ; i < s.length() ; i++) { v[i+1]=v[i]; if(s[i] == 'A') { if(t[i] == 'C') v[i+1][0]++; else if(t[i] == 'T') v[i+1][1]++; } else if(s[i] == 'C') { if(t[i] == 'A') v[i+1][2]++; else if(t[i] == 'T') v[i+1][3]++; } else { if(t[i] == 'A') v[i+1][4]++; else if(t[i] == 'C') v[i+1][5]++; } } } int get_distance(int x, int y) { int a=v[y+1][0]-v[x][0], b=v[y+1][1]-v[x][1], c=v[y+1][2]-v[x][2], d=v[y+1][3]-v[x][3], e=v[y+1][4]-v[x][4], f=v[y+1][5]-v[x][5]; int ans=0; int dif=min(a,c); ans+=dif; a-=dif,c-=dif; dif=min(b,e); ans+=dif; b-=dif,e-=dif; dif=min(d,f); ans+=dif; d-=dif,f-=dif; if(a!=d||d!=e||b!=c||c!=f) return -1; ans+=2*((max(a,c)+max(b,e)+max(d,f))/3); return ans; } void init(string aa, string bb) { s=aa,t=bb; gen(); }

Compilation message (stderr)

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