This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string st1,st2;
void init(string a,string b){
st1=a;
st2=b;
}
map<int,map<int,int>> mp;
int get_distance(int x,int y){
if(mp[x][y]){
return mp[x][y];
}
multiset<char> s1,s2;
int c = 0;
for(ll i=x;i<=y;i++){
s1.insert(st1[i]);
s2.insert(st2[i]);
if(st1[i]!=st2[i]) c++;
}
if(s1!=s2){
return -1;
}
if(s1.size()==1) return 0;
if(s1.size()==2){
if(st1[x]==st2[x]) return 0;
return 1;
}
int ans = (c+1)/2;
mp[x][y]=ans;
return ans;
}
// int main()
// {
// init("ATACAT", "ACTATA");
// cout<<get_distance(3, 5)<<endl;
// 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... |