이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <stack>
#include <set>
#include <limits>
#include <string>
#include <deque>
#include <cassert>
#include <math.h>
#include <list>
#include<numeric>
#include<map>
#include<set>
using namespace std;
struct DNA {
int a, t, c;
};
vector < pair<int, pair<DNA, DNA>>> strings;
void init(string a, string b)
{
strings.resize(a.size() + 1);
strings[0] = { 0,{ {0,0,0},{0,0,0}} };
for (int i = 0; i < a.size(); i++)
{
strings[i + 1] = strings[i];
char c1 = a[i], c2 = b[i];
if (c1 == 'A')
strings[i + 1].second.first.a++;
if (c1 == 'T')
strings[i + 1].second.first.t++;
if (c1 == 'C')
strings[i + 1].second.first.c++;
if (c2 == 'A')
strings[i + 1].second.second.a++;
if (c2 == 'T')
strings[i + 1].second.second.t++;
if (c2 == 'C')
strings[i + 1].second.second.c++;
if (c1 != c2)
strings[i + 1].first++;
}
}
int get_distance(int x, int y)
{
pair<int, pair<DNA, DNA>> tmp;
tmp.first = strings[y + 1].first - strings[x].first;
tmp.second.first.a = strings[y + 1].second.first.a - strings[x].second.first.a;
tmp.second.first.t = strings[y + 1].second.first.t - strings[x].second.first.t;
tmp.second.first.c = strings[y + 1].second.first.c - strings[x].second.first.c;
tmp.second.second.a = strings[y + 1].second.second.a - strings[x].second.second.a;
tmp.second.second.t = strings[y + 1].second.second.t - strings[x].second.second.t;
tmp.second.second.c = strings[y + 1].second.second.c - strings[x].second.second.c;
if ((tmp.second.first.a == tmp.second.second.a) && (tmp.second.first.c == tmp.second.second.c) && (tmp.second.first.t == tmp.second.second.t)) {
return (int)ceil(tmp.first / 2.0);
}
return -1;
}/*/
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
init("ATACAT", "ACTATA");
cout << get_distance(1, 3) << endl;
cout << get_distance(4, 5) << endl;
cout << get_distance(3, 5) << endl;
}*/
컴파일 시 표준 에러 (stderr) 메시지
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for (int i = 0; i < a.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... |