# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1097687 | Warinchai | Mutating DNA (IOI21_dna) | C++17 | 30 ms | 8724 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 "dna.h"
#include<bits/stdc++.h>
using namespace std;
long long vala[100005];
long long valb[100005];
long long same[100005];
int aA[100005];
int aC[100005];
int aT[100005];
int bA[100005];
int bC[100005];
int bT[100005];
long long md=1e9+7;
void init(std::string a, std::string b) {
long long ta=0,tb=0;
for(int i=0;i<a.size();i++){
vala[i+1]=((vala[i]*26)%md+a[i]-'A')%md;
valb[i+1]=((valb[i]*26)%md+b[i]-'A')%md;
aA[i+1]=aA[i],aC[i+1]=aC[i],aT[i+1]=aT[i];
bA[i+1]=bA[i],bC[i+1]=bC[i],bT[i+1]=bT[i];
if(a[i]=='A')aA[i+1]++;
else if(a[i]=='T')aT[i+1]++;
else aC[i+1]++;
if(b[i]=='A')bA[i+1]++;
else if(b[i]=='T')bT[i+1]++;
else bC[i+1]++;
//cerr<<"info:"<<vala[i+1]<<" "<<valb[i+1]<<"\n";
same[i+1]=same[i];
if(a[i]==b[i])same[i+1]++;
}
}
int get_distance(int x, int y) {
x++,y++;
//cerr<<x<<" "<<y<<" "<<"info:\n";
//cerr<<aA[y]-aA[x-1]<<" "<<aT[y]-aT[x-1]<<"\n";
//cerr<<bA[y]-bA[x-1]<<" "<<bT[y]-bT[x-1]<<"\n";
//cerr<<"\n";
if(aA[y]-aA[x-1]!=bA[y]-bA[x-1])return -1;
if(aT[y]-aT[x-1]!=bT[y]-bT[x-1])return -1;
if(aC[y]-aC[x-1]!=bC[y]-bC[x-1])return -1;
int val=y-x+1-same[y]+same[x-1];
//cerr<<"ans:\n";
//cerr<<y<<"-"<<x-1<<"-"<<same[y]<<"+"<<same[x-1]<<"\n";
return val/2;
}
Compilation message (stderr)
# | 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... |