제출 #1205499

#제출 시각아이디문제언어결과실행 시간메모리
1205499tamzidDNA 돌연변이 (IOI21_dna)C++20
43 / 100
1593 ms2376 KiB
#include <bits/stdc++.h>
#include "dna.h"
using namespace std;

string A,B;
vector<int> a_T,a_A,b_T,b_A,diff;

void init(std::string a, std::string b) {
	A = a;
	B = b;
}

bool check()
{
	return count(A.begin(),A.end(),'C') + count(B.begin(),B.end(),'C') > 0;
}

int get_distance(int x, int y) {
	if(y - x <=2 && check())
	{
		if(y - x == 0)
		{
			if(A[x] == B[x])
				return 0;
			else
				return -1;
		}
		else if(y - x == 1)
		{
			if((A[x] == B[x] && A[x+1] == B[x+1]))
				return 0;
			if((A[x] == B[x+1] && A[x+1] == B[x]))
				return 1;
			return -1;
		}
		else
		{
			int a=0,b=0,c=0;
			for(int i=x;i<=y;++i)
			{
				if(A[i] == 'A')
					++a;
				else if(A[i] == 'T')
					++b;
				else
					++c;
			}
			int d=0,e=0,f=0;
			for(int i=x;i<=y;++i)
			{
				if(B[i] == 'A')
					++d;
				else if(B[i] == 'T')
					++e;
				else
					++f;
			}
			if(a!=d || e!=b || f!=c)
			{
				return -1;
			}
			int diff1 = 0;
			for(int i=x;i<=y;++i)
			{
				if(A[i]!=B[i])
					++diff1;
			}
			if(diff1 == 1)
				return -1;
			else if(diff1 & 1)
				return 2;
			else
				return diff1/2;
		}
	}
}

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:76:1: warning: control reaches end of non-void function [-Wreturn-type]
   76 | }
      | ^
#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...