Submission #1024004

#TimeUsernameProblemLanguageResultExecution timeMemory
1024004mdn2002Mutating DNA (IOI21_dna)C++17
100 / 100
32 ms7508 KiB
/* Mayoeba Yabureru */ #include<bits/stdc++.h> using namespace std; int sum[100005][3][3]; map<char, int> mp; void init(string a, string b) { mp['A'] = 0, mp['T'] = 1, mp['C'] = 2; int n = a.size(); for (int i = 0; i < n; i ++) { sum[i][mp[a[i]]][mp[b[i]]] ++; if (i) { for (int j = 0; j < 3; j ++) { for (int z = 0; z < 3; z ++) sum[i][j][z] += sum[i - 1][j][z]; } } } } int get_distance(int x, int y) { int dsum[3][3], ans = 0; for (int i = 0; i < 3; i ++) { for (int j = 0; j < 3; j ++) { dsum[i][j] = sum[y][i][j]; if (x != 0) dsum[i][j] -= sum[x - 1][i][j]; } } dsum[0][0] = dsum[1][1] = dsum[2][2] = 0; for (int i = 0; i < 3; i ++) { for (int j = 0; j < 3; j ++) { if (i == j) continue; int ad = min(dsum[i][j], dsum[j][i]); dsum[i][j] -= ad, dsum[j][i] -= ad; ans += ad; } } int ad = min({dsum[0][1], dsum[1][2], dsum[2][0]}); dsum[0][1] -= ad, dsum[1][2] -= ad, dsum[2][0] -= ad; ans += ad * 2; ad = min({dsum[0][2], dsum[2][1], dsum[1][0]}); dsum[0][2] -= ad, dsum[2][1] -= ad, dsum[1][0] -= ad; ans += ad * 2; for (int i = 0; i < 3; i ++) { for (int j = 0; j < 3; j ++) { if (dsum[i][j]) return -1; } } 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...