Submission #633216

#TimeUsernameProblemLanguageResultExecution timeMemory
633216restingMutating DNA (IOI21_dna)C++17
100 / 100
47 ms7416 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; const int mx = 1e5+5; int ps[mx][3][3] {}; void init(std::string a, std::string b) { map<char, int> m = {{'A', 0}, {'C', 1}, {'T', 2}}; for(int i = 0; i < size(a); i++){ ps[i][m[a[i]]][m[b[i]]]++; } for(int i = 1; i < size(a); i++){ for(int a = 0; a < 3; a++){ for(int b = 0; b < 3; b++){ ps[i][a][b] += ps[i-1][a][b]; } } } } int get_distance(int x, int y) { int z[3][3]; for(int a = 0; a < 3; a++) for(int b = 0; b < 3; b++) z[a][b] = ps[y][a][b]; if(x){ for(int a = 0; a < 3; a++) for(int b = 0; b < 3; b++) z[a][b] -= ps[x-1][a][b]; } int res = 0; for(int a = 0; a < 2; a++){ for(int b = a+1; b < 3; b++){ int t = min(z[a][b], z[b][a]); res += t; z[a][b] -= t; z[b][a] -= t; } } if(!z[0][1]){ swap(z[0][1], z[1][0]); swap(z[1][2], z[2][1]); swap(z[0][2], z[2][0]); } if(z[0][1] == z[1][2] && z[1][2] == z[2][0] && !z[1][0] && !z[2][1] && !z[0][2]){ return res + z[0][1] * 2; } else{ return -1; } return 0; }

Compilation message (stderr)

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