| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1001599 | vjudge1 | Mutating DNA (IOI21_dna) | C++17 | 0 ms | 0 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back
#define pf push_front
#define pi pair<int,int>
string a,b;
const int MAX = 1e5+1;
int n;
 ll pref[MAX], wrong[MAX];
void init(string A, string B){
    a = A;
    b = B;
}
int get_distance(int x, int y){
    ll add = 0;
    ll sub = 0;
     map<char,int>mp;
     for(int i = x; i< y; i++){
    
     
        //cout << a[i]<<" " << b[i]<<endl;
       if(a[i]!=b[i]){
           add++;
           if(mp[a[i]]){
                sub++;
                mp[a[i]]--;
           }
    
             mp[b[i]]++;
       }
         
    }
    //cout << add << endl;
    return add-sub;
}
int main(){
    int n,q ;
    cin >> n >> q;
    string a,b;
    cin >> a >>b;
    
    init(a,b);
    int x,y;
    while(q--){
        cin >> x >>y;
        cout << get_distance(x,y)<<endl;
    }
}
