제출 #708957

#제출 시각아이디문제언어결과실행 시간메모리
708957grossly_overconfidentDNA 돌연변이 (IOI21_dna)C++17
56 / 100
40 ms6076 KiB
//#include "dna.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> cq, cp, aq, ap, tq, tp, m;
void init(string p, string q) {
	cq.resize(p.size() + 1);
	aq.resize(p.size() + 1);
	tq.resize(p.size() + 1);
	cp.resize(p.size() + 1);
	ap.resize(p.size() + 1);
	tp.resize(p.size() + 1);
	m.resize(p.size() + 1);
	int cps = 0, aps = 0, tps = 0, cqs = 0, aqs = 0, tqs = 0, ms = 0;
	for (int i = 1; i <= p.size(); ++i){
		int j = i - 1;
		if (q[j] != p[j]){
			ms++;
		}
		if (q[j] == 'A'){
			aqs++;
		}
		else if (q[j] == 'T'){
			tqs++;
		}
		else{
			cqs++;
		}
		if (p[j] == 'A'){
			aps++;
		}
		else if (p[j] == 'T'){
			tps++;
		}
		else{
			cps++;
		}
		cq[i] = cqs;
		aq[i] = aqs;
		tq[i] = tqs;
		cp[i] = cps;
		ap[i] = aps;
		tp[i] = tps;
		m[i] = ms;
	}
	return;

}

int get_distance(int x, int y) {
	x += 1;
	y += 1;
	if (cp[y] - cp[x - 1] == cq[y] - cq[x - 1] && ap[y] - ap[x - 1] == aq[y] - aq[x - 1] && tp[y] - tp[x - 1] == tq[y] - tq[x - 1]){
		return ((m[y] - m[x - 1]) / 2) + ((m[y] - m[x - 1]) % 2);
	}
	return -1;

}

int no(){
	string p, q;
	int i;
	cin >> p >> q >> i;
	init(p, q);
	for (int j = 0; j < i; ++j){
		int a, b;
		cin >> a >> b;
		cout << get_distance(a, b) << endl;
	}
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:15:20: 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 = 1; i <= p.size(); ++i){
      |                  ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...