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.h"
#include "bits/stdc++.h"
using namespace std;
string s, s2;
int coun(string k, char c){
int sm = 0;
for(int i = 0; i < k.size(); ++i)
sm += (k[i] == c);
return sm;
}
void init(string a, string b){
s = a;
s2 = b;
}
int get_distance(int x, int y){
int ret = -1;
string cyn_s = s.substr(x, y);
string cyn_s2 = s2.substr(x, y);
int cnt_a_s = coun(cyn_s, 'A');
int cnt_c_s = coun(cyn_s, 'C');
int cnt_t_s = coun(cyn_s, 'T');
int cnt_a_s2 = coun(cyn_s2, 'A');
int cnt_c_s2 = coun(cyn_s2, 'C');
int cnt_t_s2 = coun(cyn_s2, 'T');
if(cnt_a_s != cnt_a_s2 or cnt_t_s != cnt_t_s2 or cnt_c_s != cnt_c_s2)
return ret;
if(cyn_s == cyn_s2){
ret = 0;
return ret;
}
for(int i = 0; i < cyn_s.size(); ++i)
ret += (cyn_s[i] != cyn_s2[i]);
return ret;
}
// int main(){
// int n, q;
// scanf("%d%d", &n, &q);
// string a, b;
// cin >> a >> b;
// init(a, b);
// while(q--){
// int l, r;
// scanf("%d%d", &l, &r);
// if(r - l <= 2)
// printf("%d\n", get_distance(l, r));
// else
// puts("COZUM YOK");
// }
// return 0;
// }
Compilation message (stderr)
dna.cpp: In function 'int coun(std::string, char)':
dna.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | for(int i = 0; i < k.size(); ++i)
| ~~^~~~~~~~~~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int i = 0; i < cyn_s.size(); ++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... |