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;
typedef long long ll;
typedef vector<int> vi;
#define MAXI (int)1e5
#define pb(x) push_back(x)
int s1A[(int)1e5+5];
int s2A[(int)1e5+5];
int falsch[(int)1e5+5];
void init(string x,string y){
s1A[0] = 0;
s2A[0] = falsch[0] = 0 ;
int n = x.length();
for(int i = 0;i<n;i++){
s1A[i+1] = s1A[i];
s2A[i+1] = s2A[i];
falsch[i+1] = falsch[i];
if(x[i] == 'A') s1A[i+1]++;
if(y[i] == 'A') s2A[i+1]++;
if(x[i] != y[i]) falsch[i+1]++;
}
}
int get_distance(int x,int y){
++x; ++y;
if(s1A[y]-s1A[x-1] != s2A[y]-s2A[x-1]) return -1;
return (falsch[y]-falsch[x-1]+1) >> 1;
}
# | 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... |