Submission #958344

#TimeUsernameProblemLanguageResultExecution timeMemory
958344AC2KMutating DNA (IOI21_dna)C++17
56 / 100
34 ms12204 KiB
#include "dna.h" #include <bits/stdc++.h> #include <vector> using namespace std; int sum[300000]; int suma[3][300000], sumb[3][300000]; void init(std::string a, std::string b) { memset(sum, 0, sizeof(sum)); memset(suma, 0, sizeof(suma)); memset(suma, 0, sizeof(sumb)); for (int i = 0; i < (int)a.size(); ++i) { sum[i + 1] = sum[i] + (a[i] != b[i]); } for (int j = 0; j < 3; ++j) { for (int i = 0; i < (int)a.size(); ++i) { suma[j][i + 1] = suma[j][i] + (a[i] == ('A' + j)); sumb[j][i + 1] = sumb[j][i] + (b[i] == ('A' + j)); } } } int get_distance(int x, int y) { ++y; for (int i = 0; i < 3; ++i) { if (suma[i][y] - suma[i][x] != sumb[i][y] - sumb[i][x]) { return -1; } } return (sum[y] - sum[x] + 1) / 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...