Submission #610844

#TimeUsernameProblemLanguageResultExecution timeMemory
610844OzyMutating DNA (IOI21_dna)C++17
100 / 100
47 ms10904 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define MAX 100000 lli acu[MAX+2][3][3]; lli act[3][3]; void init(std::string a, std::string b) { lli n = a.size(); lli x,y; rep(i,0,n-1) { if (a[i] == 'A') x = 0; else if (a[i] == 'T') x = 1; else x = 2; if (b[i] == 'A') y = 0; else if (b[i] == 'T') y = 1; else y = 2; rep(e,0,2) rep(j,0,2) acu[i][e][j] = acu[i-1][e][j]; acu[i][x][y]++; } } int get_distance(int x, int y) { rep(i,0,2) rep(j,0,2) act[i][j] = acu[y][i][j]; if (x > 0) rep(i,0,2) rep(j,0,2) act[i][j] -= acu[x-1][i][j]; lli a,b,c,res = 0; a = min(act[0][2], act[2][0]); res += a; act[0][2] -= a; act[2][0] -= a; b = min(act[0][1], act[1][0]); res += b; act[0][1] -= b; act[1][0] -= b; c = min(act[1][2], act[2][1]); res += c; act[1][2] -= c; act[2][1] -= c; if (act[0][2] == act[1][0] && act[1][0] == act[2][1]) { res += act[0][2]*2; if (act[2][0] == act[0][1] && act[0][1] == act[1][2]) { res += act[2][0]*2; return res; } } return -1; }
#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...