# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
986073 | SzymonKrzywda | Mutating DNA (IOI21_dna) | C++17 | 21 ms | 2852 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 <string>
using namespace std;
const int MAXN = 100000;
int ilosc_a_t[MAXN];
int ilosc_a_c[MAXN];
int ilosc_t_c[MAXN];
int ilosc_t_a[MAXN];
int ilosc_c_a[MAXN];
int ilosc_c_t[MAXN];
void init(string a, string b){
if (a[0] == 'a'){
if (b[0] == 'c') ilosc_a_c[0] = 1;
else ilosc_a_t[0] = 1;
}
else if (a[0]=='c'){
if (b[0] == 'a') ilosc_c_a[0] = 1;
else ilosc_c_t[0] = 1;
}
else{ // t
if (b[0] == 'c') ilosc_t_c[0] = 1;
else ilosc_t_a[0] = 1;
}
for (int i=1; i<a.length(); i++){
if (a[i] == 'a'){
if (b[i] == 'c') ilosc_a_c[i] = ilosc_a_c[i-1]+1;
else ilosc_a_t[i] = ilosc_a_t[i-1] + 1;
}
else if (a[i]=='c'){
if (b[i] == 'a') ilosc_c_a[i] = ilosc_c_a[i-1]+1;
else ilosc_c_t[i] = ilosc_c_t[i-1] + 1;
}
else{ // t
if (b[i] == 'c') ilosc_t_c[i] = ilosc_t_c[i-1]+1;
else ilosc_t_a[i] = ilosc_t_a[i-1] + 1;
}
}
}
int get_distance(int x, int y){
int i_a_t = ilosc_a_t[y]-ilosc_a_t[x-1];
int i_a_c = ilosc_a_c[y]-ilosc_a_c[x-1];
int i_t_c = ilosc_t_c[y]-ilosc_t_c[x-1];
int i_t_a = ilosc_t_a[y]-ilosc_t_a[x-1];
int i_c_a = ilosc_c_a[y]-ilosc_c_a[x-1];
int i_c_t = ilosc_c_t[y]-ilosc_c_t[x-1];
if ((i_a_c+i_a_t)!=(i_t_a+i_c_a) || (i_t_c+i_t_a) != (i_c_t+i_a_t) || (i_c_a+i_c_t) != (i_a_c+i_t_c)) return -1;
int c_t = min(i_c_t,i_t_c);
int a_t = min(i_a_t,i_t_a);
int c_a = min(i_a_c,i_c_a);
i_c_a -= c_a;
i_a_c -= c_a;
i_t_c -= c_t;
i_c_t -= c_t;
i_a_t -= a_t;
i_t_a -= a_t;
int wynik = (((i_c_a+i_a_c+i_t_c+i_c_t+i_a_t+i_t_a)/3)*2)+c_t+a_t+c_a;
return wynik;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |