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>
#include "dna.h"
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> ti;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ld,ld> pld;
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front
#define ff first
#define ss second
#define MOD (int)(1e8)
#define INF (ll) (1e18)
#define all(v) (v).begin(),(v).end()
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;}
ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);}
ld pointdist(ld x, ld y, ld point) { return ((x-point)*(y-point))/abs(x-y); }
//ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
const int nx[8] = {0, 0, 1, -1,1,1,-1,-1}, ny[8] = {1, -1, 0, 0,1,-1,1,-1}; //East, West, South, North+
////////////******SOLUTION******\\\\\\\\\\\
const int MAX_N = 1e5 + 4;
int n;
int pra[MAX_N][2];
int prc[MAX_N][2];
int prt[MAX_N][2];
int pref[MAX_N];
void init(string a, string b)
{
n = a.length();
pref[0] = 0;
for(int i= 0; i <n; i++)
pref[i+1] = pref[i] + (a[i] != b[i]);
pra[0][0] = pra[0][1] = prc[0][0] = prc[0][1] = prt[0][0] = prt[0][1] = 0;
for(int i = 0; i<n; i ++)
{
pra[i+1][0] = pra[i][0] + (a[i] == 'A');
prc[i+1][0] = prc[i][0] + (a[i] == 'C');
prt[i+1][0] = prt[i][0] + (a[i] == 'T');
pra[i+1][1] = pra[i][1] + (b[i] == 'A');
prc[i+1][1] = prc[i][1] + (b[i] == 'C');
prt[i+1][1] = prt[i][1] + (b[i] == 'T');
}
}
int get_distance(int x, int y)
{
if(pra[y+1][0] - pra[x][0] != pra[y+1][1] - pra[x][1])
return -1;
if(prc[y+1][0] - prc[x][0] != prc[y+1][1] - prc[x][1])
return -1;
int d = (pref[y+1]- pref[x])/3 + 1;
return d;
}
/*
Identify problem diagram: Brute force, Greedy, Dynamic Programming, Divide and Conquer
Reformulate the problem into something more theoretical
!!!!! IMPLICIT GRAPH ??????
!!!!! PAY ATTENTION TO THE CONSTRAINTS: DP nD ? BF ? BITMASKING ?
!!!!! SOLVE THE SUBTASKS FIRST: IT'S TOTALLY OK NOT TO SOLVE THE PROBLEM ENTIRELY
Search for multiple approaches: select the seemingly optimal one
Remember that you're the king of CP
Change your approach
Imagine Corner cases before submitting
Don't spend too much time on the problem: move on !
*/
Compilation message (stderr)
dna.cpp:27:1: warning: multi-line comment [-Wcomment]
27 | ////////////******SOLUTION******\\\\\\\\\\\
| ^
# | 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... |