Submission #574750

#TimeUsernameProblemLanguageResultExecution timeMemory
574750four_specksMutating DNA (IOI21_dna)C++17
56 / 100
35 ms6676 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; inline namespace tc { } // namespace tc namespace { array<vector<int>, 3> pref_a, pref_b; vector<int> diff; } // namespace const map<char, int> mp = {{pair('A', 0), pair('T', 1), pair('C', 2)}}; void init(string a, string b) { int n = (int)a.length(); pref_a.fill(vector<int>(n + 1, 0)), pref_b.fill(vector<int>(n + 1, 0)); diff = vector<int>(n + 1, 0); for (int i = 0; i < n; i++) { for (int c = 0; c < 3; c++) pref_a[c][i + 1] = pref_a[c][i], pref_b[c][i + 1] = pref_b[c][i]; pref_a[mp.at(a[i])][i + 1]++, pref_b[mp.at(b[i])][i + 1]++; diff[i + 1] = diff[i] + (a[i] != b[i]); } } int get_distance(int x, int y) { ++y; bool ok = 1; for (int c = 0; c < 3; c++) ok &= pref_a[c][y] - pref_a[c][x] == pref_b[c][y] - pref_b[c][x]; if (ok) return (diff[y] - diff[x] + 1) / 2; 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...