This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#include "dna.h"
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pii pair<int,int>
using namespace std;
const int N=1e5+5;
int n,m,T,k;
int A[N][3],B[N][3],C[N][3][3];
void init(std::string a, std::string b) {
n=a.size(); a=" "+a; b=" "+b;
for (int i=1; i<=n; i++) {
if (a[i]=='T') a[i]='B';
if (b[i]=='T') b[i]='B';
int ia=a[i]-'A',ib=b[i]-'A';
for (char c='A'; c<='C'; c++) {
int ic=c-'A';
A[i][ic]=A[i-1][ic]+(a[i]==c);
B[i][ic]=B[i-1][ic]+(b[i]==c);
}
for (int x=0; x<3; x++) {
for (int y=0; y<3; y++) {
C[i][x][y]=C[i-1][x][y];
}
}
C[i][ia][ib]++;
}
}
int get_distance(int x, int y) {
x++; y++;
int AA[3],BB[3],CC[3][3];
for (int i=0; i<3; i++) {
AA[i]=A[y][i]-A[x-1][i];
BB[i]=B[y][i]-B[x-1][i];
if (AA[i]!=BB[i]) return -1;
for (int j=0; j<3; j++) {
CC[i][j]=C[y][i][j]-C[x-1][i][j];
}
}
int AB=min(CC[0][1],CC[1][0]);
CC[0][1]-=AB;
CC[1][0]-=AB;
int AC=min(CC[0][2],CC[2][0]);
CC[0][2]-=AC;
CC[2][0]-=AC;
int BC=min(CC[1][2],CC[2][1]);
CC[1][2]-=BC;
CC[2][1]-=BC;
int cnt=0;
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
if (i==j) continue;
cnt+=CC[i][j];
}
}
cnt/=3; cnt*=2;
return AB+AC+BC+cnt;
}
Compilation message (stderr)
dna.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
1 | #pragma GCC diagnostic warning "-std=c++11"
| ^~~~~~~~~~~~
# | 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... |