Submission #838987

#TimeUsernameProblemLanguageResultExecution timeMemory
838987AlfraganusMutating DNA (IOI21_dna)C++17
0 / 100
79 ms33356 KiB
#include "dna.h" // #include "grader.cpp" #include <bits/stdc++.h> using namespace std; vector<vector<int>> as, bs; vector<vector<vector<int>>> p; void init(std::string a, std::string b) { int n = a.size(); for (int i = 0; i < n; i++) { if (a[i] == 'T') a[i] = 'B'; if (b[i] == 'T') b[i] = 'B'; } p.resize(n + 1, vector<vector<int>> (3, vector<int> (3))); as.resize(n + 1, vector<int>(3)); bs.resize(n + 1, vector<int>(3)); for (int i = 0; i < n; i++) { as[i + 1] = as[i]; as[i + 1][a[i] - 'A']++; bs[i + 1] = bs[i]; bs[i + 1][b[i] - 'A']++; p[i + 1] = p[i]; p[i + 1][b[i] - 'A'][a[i] - 'A']++; } } int get_distance(int x, int y) { x ++; y ++; if (as[y][0] - as[x - 1][0] == bs[y][0] - bs[x - 1][0] && as[y][1] - as[x - 1][1] == bs[y][1] - bs[x - 1][1] && as[y][2] - as[x - 1][2] == bs[y][2] - bs[x - 1][2]) { int ans = y - x; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) ans -= min(p[y][i][j] - p[x - 1][i][j], p[y][j][i] - p[x - 1][j][i]); return ans; } return -1; }
#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...