Submission #440906

#TimeUsernameProblemLanguageResultExecution timeMemory
440906jlozano254Mutating DNA (IOI21_dna)C++17
56 / 100
180 ms39696 KiB
#include "dna.h" #include <map> #include <vector> const int MAXN = 1e5 + 5; std::vector<std::map<char, int>> aDP(MAXN); std::vector<std::map<char, int>> bDP(MAXN); void init(std::string a, std::string b) { for (int i = 0; i < (int) 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; }
#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...