Submission #563332

#TimeUsernameProblemLanguageResultExecution timeMemory
563332rafatoaMutating DNA (IOI21_dna)C++17
0 / 100
31 ms2444 KiB
#include <bits/stdc++.h> using namespace std; int n; string a, b; void init(string ain, string bin){ n = ain.size(); a = ain, b = bin; } int ix(char c){ if(c == 'A') return 0; else if(c == 'C') return 1; else return 2; } int get_distance(int x, int y){ x--; y--; int v[3][3]; for(int i=0; i<3; i++) for(int j=0; j<3; j++) v[i][j] = 0; int bal[3]; bal[0] = bal[1] = bal[2] = 0; for(int i=x; i<=y; i++){ bal[ix(a[i])]++; bal[ix(b[i])]--; if(a[i] == b[i]) continue; v[ix(a[i])][ix(b[i])]++; } if(bal[0] != 0 || bal[1] != 0 || bal[2] != 0) return -1; int ans = 0; if(v[0][1] >= v[1][0]){ ans += v[1][0]; v[0][1] -= v[1][0]; v[1][0] = 0; } else { ans += v[0][1]; v[1][0] -= v[0][1]; v[0][1] = 0; } if(v[0][2] >= v[2][0]){ ans += v[2][0]; v[0][2] -= v[2][0]; v[2][0] = 0; } else { ans += v[0][2]; v[2][0] -= v[0][2]; v[0][2] = 0; } if(v[1][2] >= v[2][1]){ ans += v[2][1]; v[1][2] -= v[2][1]; v[2][1] = 0; } else { ans += v[1][2]; v[2][1] -= v[1][2]; v[1][2] = 0; } for(int i=0; i<3; i++) for(int j=0; j<3; j++) if(i != j) ans += v[i][j]; return ans; }
#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...