Submission #437510

#TimeUsernameProblemLanguageResultExecution timeMemory
437510grtMutating DNA (IOI21_dna)C++17
100 / 100
60 ms7708 KiB
#include <bits/stdc++.h> #define PB push_back #define ST first #define ND second #define _ ios_base::sync_with_stdio(0); cin.tie(0); //mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); using namespace std; using ll = long long; using pi = pair<int,int>; using vi = vector<int>; const int nax = 100 * 1000 + 10; int cnt[nax][10]; int cur[10]; map<char,int>odp; void init(string a, string b) { odp['A'] = 0; odp['T'] = 1; odp['C'] = 2; for(int i = 1; i <= (int)a.size(); ++i) { for(int j = 0; j < 9; ++j) { cnt[i][j] = cnt[i - 1][j]; } int x = odp[a[i - 1]] * 3 + odp[b[i - 1]]; cnt[i][x]++; } } int get_distance(int x, int y) { y++; for(int i = 0; i < 9; ++i) { cur[i] = cnt[y][i] - cnt[x][i]; } if(cur[0] + cur[3] + cur[6] != cur[0] + cur[1] + cur[2]) return -1; if(cur[1] + cur[4] + cur[7] != cur[3] + cur[4] + cur[5]) return -1; if(cur[2] + cur[5] + cur[8] != cur[6] + cur[7] + cur[8]) return -1; int ans = 0; ans = min(cur[1], cur[3]) + max(cur[2], cur[6]) + max(cur[5], cur[7]); return ans; } //~ int main() { //~ init("ATACAT", "ACTATA"); //~ cout << get_distance(1, 3) << "\n"; //~ cout << get_distance(4, 5) << "\n"; //~ cout << get_distance(3, 5) << "\n"; //~ }
#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...