제출 #985924

#제출 시각아이디문제언어결과실행 시간메모리
985924LucaIlieDNA 돌연변이 (IOI21_dna)C++17
71 / 100
26 ms6304 KiB
#include "dna.h" #include <iostream> using namespace std; #define nmax 100000 int n; int AtoT[nmax], AtoC[nmax], TtoA[nmax], TtoC[nmax], CtoA[nmax], CtoT[nmax]; int valAtoT, valAtoC, valTtoA, valTtoC, valCtoA, valCtoT; string A, B; void init( string a, string b ) { int i; n = a.size(); A = a; B = b; a = '0' + a; b = '0' + b; for( i = 1; i <= n; i++ ) { AtoT[i] = AtoT[i - 1]; AtoC[i] = AtoC[i - 1]; TtoA[i] = TtoA[i - 1]; TtoC[i] = TtoC[i - 1]; CtoA[i] = CtoA[i - 1]; CtoT[i] = CtoT[i - 1]; if( a[i] == b[i] ) continue; if( a[i] == 'A' ) { if( b[i] == 'T' ) AtoT[i]++; else AtoC[i]++; } else if( a[i] == 'C' ) { if( b[i] == 'T' ) CtoT[i]++; else CtoA[i]++; } else { if( b[i] == 'A' ) TtoA[i]++; else TtoC[i]++; } } } int get_distance( int x, int y ) { int minn, rez = 0; x++; y++; valAtoC = AtoC[y] - AtoC[x - 1]; valAtoT = AtoT[y] - AtoT[x - 1]; valTtoC = TtoC[y] - TtoC[x - 1]; valTtoA = TtoA[y] - TtoA[x - 1]; valCtoA = CtoA[y] - CtoA[x - 1]; valCtoT = CtoT[y] - CtoT[x - 1]; minn = min( valAtoC, valCtoA ); valAtoC -= minn; valCtoA -= minn; rez += minn; minn = min( valAtoT, valTtoA ); valAtoT -= minn; valTtoA -= minn; rez += minn; minn = min( valCtoT, valTtoC ); valCtoT -= minn; valTtoC -= minn; rez += minn; //cout << "rez " << rez << "\n"; if( valCtoA == valAtoT && valAtoT == valTtoC && valCtoT == valTtoA && valTtoA == valAtoC ) return rez + 2 * valCtoA + 2 * valAtoC; return -1; }
#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...