이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "dna.h"
using namespace std;
// const int N = 100000;
const int N = 6;
bitset<N> bita, bitb;
void print_bitset(bitset<N> b) {
for (int i=0; i<N; i++) {
cout << b[i];
}
cout << endl;
}
void init(string a, string b) {
for (int i=0; i<(int)a.length(); i++) {
bita[i] = a[i] == 'B';
bitb[i] = b[i] == 'B';
}
// cout << "init:" << endl;
// print_bitset(bita);
// print_bitset(bitb);
// cout << endl;
}
int get_distance(int x, int y) {
// // brute force not finished
// int c = 0;
// int last = y;
// for (int i=x; i<=y; i++) {
// if (a[i] == b[i]) {
// continue;
// } else {
// // a[i] != b[i]
// // find last j <= such that a[i] == b[j]
// for (int j=last; j>i; j--) {
// }
// }
// }
int len = y-x+1;
bitset<N> ones = (1<<len)-1;
bitset<N> ra = (bita >> x) & ones;
int acount = ra.count();
bitset<N> rb = (bitb >> x) & ones;
int bcount = ra.count();
// number of B's in
if (acount != bcount) {
return -1;
}
// find number of overlapping
int overlap = (ra&rb).count();
int distance = acount - overlap;
return distance;
// cout << "len: " << len << endl;
// cout << "ones" << endl;
// print_bitset(ones);
// cout << "acount: " << acount << endl;
// cout << "bcount: " << bcount << endl;
// cout << "overlap: " << overlap << endl;
// cout << distance << endl;
}
// int main() {
// // init("AAABBB", "BBBAAA");
// init("ATACAT", "ACTATA");
// get_distance(1, 3);
// get_distance(4, 5);
// get_distance(3, 5);
// return 0;
// }
# | 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... |