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 "dna_ioi.h"
#include <bits/stdc++.h>
using namespace std;
string s, t;
vector<int>v[100005];
void init(std::string a, std::string b) {
s= a, t = b;
v[0].push_back(0);
v[0].push_back(0);
v[0].push_back(0);
v[0].push_back(0);
v[0].push_back(0);
v[0].push_back(0);
int cnt = 0, cnt2= 0, cnt3 = 0, cnt4= 0 , cnt5 = 0, cnt6= 0;
for(int i=0;i<a.length();i++){
if(s[i] == 'A' && t[i] == 'T')cnt++;
else if(s[i] == 'A' && t[i] == 'C')cnt2++;
else if(s[i] == 'T' && t[i] == 'A')cnt3++;
if(t[i] == 'C' && s[i] == 'T')cnt4++;
else if(t[i] == 'A' && s[i] == 'C')cnt5++;
else if(s[i] == 'C' && t[i] == 'T')cnt6++;
v[i+1].push_back(cnt);
v[i+1].push_back(cnt2);
v[i+1].push_back(cnt3);
v[i+1].push_back(cnt4);
v[i+1].push_back(cnt5);
v[i+1].push_back(cnt6);
}
}
int get_distance(int x, int y) {
x++;
y++;
int cnt = v[y][0] - v[x-1][0], cnt2 = v[y][1] - v[x-1][1], cnt3 = v[y][2] - v[x-1][2], cnt4= v[y][3] - v[x-1][3], cnt5 = v[y][4] - v[x-1][4], cnt6 = v[y][5] - v[x-1][5];
int ans = 0;
ans += min(cnt, cnt3);
cnt -= ans;
cnt3 -= ans;
ans += min(cnt2, cnt5);
int d = min(cnt2, cnt5);
cnt2 -= d;
cnt5 -= d;
ans += min(cnt4, cnt6);
d = min(cnt4, cnt6);
cnt4 -= d;
cnt6 -= d;
if(cnt3 != cnt2 || cnt2 != cnt6 || cnt3 != cnt6)return -1;
if(cnt != cnt4 || cnt4 != cnt5 || cnt != cnt5)return -1;
return ans + cnt*2 + cnt3*2;
}
Compilation message (stderr)
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for(int i=0;i<a.length();i++){
| ~^~~~~~~~~~~
# | 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... |