Submission #1116322

#TimeUsernameProblemLanguageResultExecution timeMemory
1116322jtrhMutating DNA (IOI21_dna)C++17
100 / 100
33 ms6420 KiB
#include "dna.h" #include <vector> std::vector<int> ca, ct, cc, aa, at, tc; void init(std::string a, std::string b) { ca.resize(a.size() + 1); ct.resize(a.size() + 1); cc.resize(a.size() + 1); aa.resize(a.size() + 1); at.resize(a.size() + 1); tc.resize(a.size() + 1); for (int i = 0; i < a.size(); ++i) { ca[i + 1] = ca[i] + (a[i] == 'A') - (b[i] == 'A'); ct[i + 1] = ct[i] + (a[i] == 'T') - (b[i] == 'T'); cc[i + 1] = cc[i] + (a[i] == 'C') - (b[i] == 'C'); aa[i + 1] = aa[i] + ((a[i] == 'A') != (b[i] == 'A')); at[i + 1] = at[i] + (a[i] == 'A' && b[i] == 'T') - (a[i] == 'T' && b[i] == 'A'); tc[i + 1] = tc[i] + ((a[i] == 'T' && b[i] == 'C') || (a[i] == 'C' && b[i] == 'T')); } } int get_distance(int x, int y) { if (ca[x] != ca[y + 1] || ct[x] != ct[y + 1] || cc[x] != cc[y + 1]) { return -1; } return (aa[y + 1] - aa[x] + abs(at[y + 1] - at[x]) + tc[y + 1] - tc[x]) / 2; }

Compilation message (stderr)

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