제출 #509869

#제출 시각아이디문제언어결과실행 시간메모리
509869YaserFaisalDNA 돌연변이 (IOI21_dna)C++17
35 / 100
40 ms7712 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std ; int ps[100009][10] ; 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]++ ; for ( int j = 1 ; j <= 6 ; 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++ ; 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) ; if ( fi == s && fi == t && t == s ) ans+=2*fi ; else ans = -1 ; return ans ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...