Submission #437092

#TimeUsernameProblemLanguageResultExecution timeMemory
437092tutisMutating DNA (IOI21_dna)C++17
35 / 100
54 ms6016 KiB
#include "dna.h" int C[3][3][100001]; void init(std::string a, std::string b) { int n = a.size(); for (int i = 0; i < n; i++) { for (int x = 0; x < 3; x++) for (int y = 0; y < 3; y++) C[x][y][i + 1] = C[x][y][i]; int c1 = 0; int c2 = 0; if (a[i] == 'A') c1 = 1; if (a[i] == 'T') c1 = 2; if (b[i] == 'A') c2 = 1; if (b[i] == 'T') c2 = 2; C[c1][c2][i + 1]++; } } int get_distance(int x, int y) { int A[3][3]; for (int a = 0; a < 3; a++) { for (int b = 0; b < 3; b++) { A[a][b] = C[a][b][y + 1] - C[a][b][x]; } } for (int a = 0; a < 3; a++) { int bal = 0; for (int b = 0; b < 3; b++) { bal += A[a][b]; bal -= A[b][a]; } if (bal != 0) return -1; } int ans = 0; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { if (x != y) ans += A[x][y]; } } ans /= 2; 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...