Submission #1142205

#TimeUsernameProblemLanguageResultExecution timeMemory
1142205programming23Mutating DNA (IOI21_dna)C++20
43 / 100
1597 ms2372 KiB
#include "bits/stdc++.h" using namespace std; string stringA=""; string stringB=""; void init(string a, string b) { stringA = a; stringB = b; } int get_distance(int x, int y) { string sA = stringA; string sB = stringB; map<char, int> countsB; map<char, int> countsA; int count = 0; for(int i=x; i <= y; i++){ if(countsA.find(sA[i]) == countsA.end()){ countsA[sA[i]] = 1; }else{ countsA[sA[i]] +=1; } if(countsB.find(sB[i]) == countsB.end()){ countsB[sB[i]] = 1; }else{ countsB[sB[i]] +=1; } } int lnA = countsA.size(); int lnB = countsB.size(); if(lnA != lnB){ return -1; }for(auto c: countsA){ if(countsA[c.first] != countsB[c.first]){ return -1; } } if(lnA == 2 && lnB == 2){ for(int i=x; i <= y; i++){ if(sA[i] != sB[i]){ count+=1; } } count = count/2; } else{ int i=x; while (i <= y && sA != sB){ char c = sA[i]; if(c == sB[i]){ i++; continue; } for(int z=i+1; z <= y; z++){ if(sA[z] != sB[i] || sA[z] == sB[z]){ continue; } sA[i] = sA[z]; sA[z] = c; i++; count++; } } } return count; }
#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...