제출 #871454

#제출 시각아이디문제언어결과실행 시간메모리
871454peraDNA 돌연변이 (IOI21_dna)C++17
56 / 100
26 ms8604 KiB
#include<bits/stdc++.h> #include"dna.h" using namespace std; //#define int long long const int N = 2e5 + 1; int p[N] , A[N][3][2]; void init(string a , string b){ for(int i = 0;i < (int)a.size();i ++){ p[i] = 0; for(int k = 0;k < 3;k ++){ for(int m = 0;m < 2;m ++){ A[i][k][m] = 0; } } } map<char , int> to; to['A'] = 1 , to['C'] = 2 , to['T'] = 0; for(int i = 0;i < (int)a.size();i ++){ if(i){ p[i] = p[i - 1]; for(int k = 0;k < 3;k ++){ for(int m = 0;m < 2;m ++){ A[i][k][m] = A[i - 1][k][m]; } } } p[i] += (a[i] != b[i]); A[i][to[a[i]]][0]++; A[i][to[b[i]]][1]++; } } int get_distance(int x , int y){ for(int k = 0;k < 3;k ++){ int a = A[y][k][0] - (x ? A[x - 1][k][0] : 0), b = A[y][k][1] - (x ? A[x - 1][k][1] : 0); if(a != b) return -1; } return (p[y] - p[x - 1] + 1) / 2; }
#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...