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;
}
int get_distance(int x,int y){
multiset<char> s1,s2;
int c = 0;
for(ll i=x;i<=y;i++){
s1.insert(st1[i]);
s2.insert(st2[i]);
}
if(s1!=s2){
return -1;
}
map<int,int> mp;
for(ll i=x;i<=y;i++){
for(ll j=x;j<=y;j++){
if(st1[i]==st2[j]&&!mp[j]){
c += (i!=j);
mp[j]++;
}
}
}
ll ans = (c+1)/2;
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... |