Submission #705562

#TimeUsernameProblemLanguageResultExecution timeMemory
705562jakobrsMutating DNA (IOI21_dna)C++17
100 / 100
36 ms5384 KiB
#include <iostream> #include <vector> struct Count { int at, ca, tc; int qw; Count() : at(0), ca(0), tc(0), qw(0) {} inline Count operator-(Count rhs) const { Count result = *this; result.at -= rhs.at; result.ca -= rhs.ca; result.tc -= rhs.tc; result.qw -= rhs.qw; return result; } }; std::vector<Count> prefixes; void init(std::string a, std::string b) { prefixes.reserve(a.size() + 1); Count count; prefixes.push_back(count); for (size_t i = 0; i < a.size(); i++) { if (a[i] == 'A' && b[i] == 'T') count.at += 1; if (a[i] == 'T' && b[i] == 'A') count.at -= 1; if (a[i] == 'C' && b[i] == 'A') count.ca += 1; if (a[i] == 'A' && b[i] == 'C') count.ca -= 1; if (a[i] == 'T' && b[i] == 'C') count.tc += 1; if (a[i] == 'C' && b[i] == 'T') count.tc -= 1; if (a[i] != b[i]) count.qw += 1; prefixes.push_back(count); } } int get_distance(int x, int y) { y += 1; Count count = prefixes[y] - prefixes[x]; if (!(count.at == count.ca && count.ca == count.tc)) return -1; return (count.qw + std::abs(count.at)) / 2; }
#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...