Submission #1021966

#TimeUsernameProblemLanguageResultExecution timeMemory
1021966HappyCapybaraMutating DNA (IOI21_dna)C++17
100 / 100
46 ms6448 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; vector<vector<int>> ps; void init(string a, string b){ ps.resize(6, vector<int>(a.size()+1, 0)); for (int i=0; i<a.size(); i++){ for (int j=0; j<6; j++) ps[j][i+1] = ps[j][i]; if (a[i] == 'A' && b[i] == 'T') ps[0][i+1]++; if (a[i] == 'A' && b[i] == 'C') ps[1][i+1]++; if (a[i] == 'T' && b[i] == 'A') ps[2][i+1]++; if (a[i] == 'T' && b[i] == 'C') ps[3][i+1]++; if (a[i] == 'C' && b[i] == 'A') ps[4][i+1]++; if (a[i] == 'C' && b[i] == 'T') ps[5][i+1]++; } } int get_distance(int x, int y) { vector<int> v(6); for (int i=0; i<6; i++) v[i] = ps[i][y+1] - ps[i][x]; int p = min(v[0], v[2])+min(v[1], v[4])+min(v[3], v[5]); if (v[0]+v[1] != v[2]+v[4] || v[2]+v[3] != v[0]+v[5] || v[4]+v[5] != v[1]+v[3]) return -1; else return p + (v[0]+v[1]+v[2]+v[3]+v[4]+v[5]-2*p)/3 * 2; }

Compilation message (stderr)

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