Submission #440775

#TimeUsernameProblemLanguageResultExecution timeMemory
440775jlozano254Mutating DNA (IOI21_dna)C++17
56 / 100
196 ms44188 KiB
#include "dna.h" #include <map> #include <vector> std::vector<std::map<char, int>> aDP; std::vector<std::map<char, int>> bDP; void init(std::string a, std::string b) { std::vector<std::map<char, int>> aux(a.length() + 1); aDP = aux; bDP = aux; if (a[0] != b[0]) { aDP[1][a[0]]++; bDP[1][b[0]]++; } for (int i = 1; i < a.length(); ++i) { aDP[i + 1] = aDP[i]; bDP[i + 1] = bDP[i]; if (a[i] != b[i]) { aDP[i + 1][a[i]]++; bDP[i + 1][b[i]]++; } } } int get_distance(int x, int y) { y++; int aAcumA = aDP[y]['A'] - aDP[x]['A']; int aAcumC = aDP[y]['C'] - aDP[x]['C']; int aAcumT = aDP[y]['T'] - aDP[x]['T']; int bAcumA = bDP[y]['A'] - bDP[x]['A']; int bAcumC = bDP[y]['C'] - bDP[x]['C']; int bAcumT = bDP[y]['T'] - bDP[x]['T']; if (aAcumA != bAcumA || aAcumC != bAcumC || aAcumT != bAcumT) return -1; int total = aAcumA + aAcumC + aAcumT; int moves = total >> 1; return (total & 1) ? moves + 1 : moves; }

Compilation message (stderr)

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