| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 670557 | sleepntsheep | Mutating DNA (IOI21_dna) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <string.h>
#include <string>
using namespace std;
#define N 100005
#define ABS(x) ((x) < 0 ? (-(x)) : (x))
char a[N], b[N];
int unlike[N];
int counta[N][3];
int countb[N][3];
void init(string a_, string b_) {
strcpy(a+1, a_.c_str());
strcpy(b+1, b_.c_str());
for (int i = 1; a[i]; i++) {
unlike[i] = unlike[i-1] + !!(a[i] - b[i]);
for (int j = 0; j < 3; j++) {
counta[i][j] = counta[i-1][j] + (j["ATC"] == a[i]);
countb[i][j] = countb[i-1][j] + (j["ATC"] == b[i]);
}
}
}
int get_distance(int x, int y) {
x++;y++;
for (int i = 0; i < 3; i++)
if (counta[y][i] - counta[x-1][i] != countb[y][i] - countb[x-1][i])
return -1;
return (unlike[y] - unlike[x-1]) - 1;
}
int main(void) {
init("ATACAT", "ACTATA");
printf("%d\n", get_distance(1, 3));
return 0;
}
