Submission #969281

#TimeUsernameProblemLanguageResultExecution timeMemory
969281androMutating DNA (IOI21_dna)C++17
0 / 100
41 ms2620 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std; string A, B; void init(std::string a, std::string b) { A = a; B = b; } int get_distance(int x, int y) { map<char,int> M, M1; for(int i = x; i <= y; i++) { M[A[i]] += 1; M1[B[i]] += 1; } if(M['A'] != M1['A'] || M['T'] != M1['T'] || M['C'] != M1['C']) { return - 1; } int ans = 0; for(int i = x; i <= y; i++) { if(A[i] == B[i]) { continue; } int ok = 0; for(int j = i + 1; j <= y; j++) { if(A[i] == B[j] && A[j] == B[i]) { swap(A[i], A[j]); ok = 1; break; } } ans += 1; if(! ok) { for(int j = i + 1; j <= y; j++) { if(B[i] == A[j]) { swap(A[i], A[j]); } } } } return ans; } /* int main() { init("ATACAT", "ACTATA"); cout << get_distance(0, 5); }*/
#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...