Submission #831960

#TimeUsernameProblemLanguageResultExecution timeMemory
831960JoksimKaktusMutating DNA (IOI21_dna)C++17
0 / 100
25 ms2404 KiB
#include <bits/stdc++.h> #include <iostream> #include <vector> #include <cmath> #include <queue> #include <map> #include <algorithm> #include <iomanip> #include <set> //#include "dna.h" #include <cstdio> #include <cassert> #include <string> using namespace std; string A; string B; void init(string a,string b){ A = a; B = b; } int get_distance(int x, int y) { vector<int> v(6, 0); for (int i = x; i <= y; i++) { if (A[i] != B[i]) { if (A[i] == 'A') { if (B[i] == 'T') v[0]++; // A-T imbalance if (B[i] == 'C') v[1]++; // A-C imbalance } else if (A[i] == 'C') { if (B[i] == 'A') v[2]++; // C-A imbalance if (B[i] == 'T') v[3]++; // C-T imbalance } else { if (B[i] == 'A') v[4]++; // T-A imbalance if (B[i] == 'C') v[5]++; // T-C imbalance } } } if (v[0] + v[1] == v[2] + v[3] && v[0] + v[1] == v[4] + v[5]) { int res = 0; res += min(v[0], v[4]); res += min(v[1], v[2]); res += min(v[3], v[5]); res += 2 * abs(v[0] - v[4]); // Corrected calculation return res; } else { 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...