Submission #528782

#TimeUsernameProblemLanguageResultExecution timeMemory
528782happypotatoMutating DNA (IOI21_dna)C++17
56 / 100
34 ms6248 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; const int mxN = 1e5 + 1; int ps[2][mxN][3]; map<char, int> conv = {{'A', 0}, {'C', 1}, {'T', 2}}; void init(string a, string b) { int n = a.length(); for (int i = 1; i <= n; i++) { for (int j = 0; j < 3; j++) { ps[0][i][j] = ps[0][i - 1][j]; ps[1][i][j] = ps[1][i - 1][j]; } if (a[i - 1] == b[i - 1]) continue; ps[0][i][conv[a[i - 1]]]++; ps[1][i][conv[b[i - 1]]]++; } } int get_distance(int x, int y) { x++; y++; int ans = 0; for (int i = 0; i < 3; i++) { if (ps[0][y][i] - ps[0][x - 1][i] != ps[1][y][i] - ps[1][x - 1][i]) return -1; ans += ps[0][y][i] - ps[0][x - 1][i]; } return ans / 2 + ans % 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...