# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
510021 | YaserFaisal | Mutating DNA (IOI21_dna) | C++17 | 38 ms | 11636 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>
#include "dna.h"
using namespace std ;
int ps[100009][20] ;
void init ( string a , string b )
{
int n = a.size() ;
for ( int i = 0 ; i < n ; i++ )
{
if ( a[i] == 'A' && b[i] == 'C' ) ps[i+1][1]++ ;
if ( a[i] == 'C' && b[i] == 'A' ) ps[i+1][2]++ ;
if ( a[i] == 'C' && b[i] == 'T' ) ps[i+1][3]++ ;
if ( a[i] == 'T' && b[i] == 'C' ) ps[i+1][4]++ ;
if ( a[i] == 'T' && b[i] == 'A' ) ps[i+1][5]++ ;
if ( a[i] == 'A' && b[i] == 'T' ) ps[i+1][6]++ ;
if ( a[i] == 'A' ) ps[i+1][7]++ ;
if ( a[i] == 'C' ) ps[i+1][8]++ ;
if ( a[i] == 'T' ) ps[i+1][9]++ ;
if ( b[i] == 'A' ) ps[i+1][10]++ ;
if ( b[i] == 'C' ) ps[i+1][11]++ ;
if ( b[i] == 'T' ) ps[i+1][12]++ ;
for ( int j = 1 ; j <= 12 ; j++ ) ps[i+1][j]+=ps[i][j] ;
}
}
// ACT
// 1 AC
// 2 CA
// 3 CT
// 4 TC
// 5 TA
// 6 AT
int get_distance ( int x , int y )
{
y++ ;
for ( int i = 7 ; i <= 9 ; i++ )
{
if ( (ps[y][i]-ps[x][i]) != (ps[y][i+3]-ps[x][i+3]) ) return -1 ;
}
int ans = 0 ;
int a = ps[y][1] - ps[x][1] ;
int b = ps[y][2] - ps[x][2] ;
int c = ps[y][3] - ps[x][3] ;
int d = ps[y][4] - ps[x][4] ;
int e = ps[y][5] - ps[x][5] ;
int f = ps[y][6] - ps[x][6] ;
//cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl ;
int fi = max(a,b) - min(a,b) ;
ans+=min(a,b) ;
int s = max(c,d) - min(c,d) ;
ans+=min(c,d) ;
int t = max(e,f) - min(e,f) ;
ans+=min(e,f) ;
ans+=2*fi ;
return ans ;
}
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... |