제출 #1343738

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

string a,b;
void init(string f, string s) {
    a=f;b=s;
}

int get_distance(int x, int y) {
    if(x==y and a[x]==b[x])return 0;
    if(x==y and a[x]!=b[x])return -1;
    if(y-x==1 and a[x]==b[x] and a[y]==b[y])return 0;
    if(y-x==1 and a[x]==b[y] and a[y]==b[x])return 1;
    if(y-x==1)return -1;
	int c=0;
	map<char,int> mp;
	for(int i=x;i<=y;i++){
	    if(a[i]==b[i])++c;
	}
	for(int i=x;i<=y;i++){
	    mp[a[i]]++;
	}
	for(int i=x;i<=y;i++){
	    mp[b[i]]--;
	}
	for(int i=x;i<=y;i++){
	    if(mp[a[i]]!=0)return -1;
	}
	if(c==0)return 2;
	if(c==1)return 1;
	if(c==3)return 0;
	return -1;
}
#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...