제출 #599224

#제출 시각아이디문제언어결과실행 시간메모리
599224definitelynotmeeDNA 돌연변이 (IOI21_dna)C++17
100 / 100
47 ms9748 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define all(x) x.begin(), x.end() using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template<typename T> using matrix= vector<vector<T>>; array<vector<array<int,3>>,2> ct; vector<array<array<int,3>,3>> fix; map<char,int> dic = {{'A',0},{'C',1},{'T',2}}; void init(std::string a, std::string b) { int n = a.size(); for(int i = 0; i < 2; i++){ ct[i] = vector<array<int,3>>(n+1); } fix = vector<array<array<int,3>,3>>(n+1); for(int i = 1; i <= n; i++){ ct[0][i] = ct[0][i-1]; ct[0][i][dic[a[i-1]]]++; } for(int i = 1; i <= n; i++){ ct[1][i] = ct[1][i-1]; ct[1][i][dic[b[i-1]]]++; fix[i] = fix[i-1]; fix[i][dic[a[i-1]]][dic[b[i-1]]]++; } } int get_distance(int x, int y) { array<int,3> c1 = ct[0][y+1], c2 = ct[1][y+1]; for(int i = 0; i < 3; i++) c1[i]-=ct[0][x][i], c2[i] -=ct[1][x][i]; if(c1!=c2) return -1; int resp = 0; array<array<int,3>,3> totfix = fix[y+1]; for(int i = 0; i < 3; i++){ for(int j = 0; j < 3; j++){ totfix[i][j]-=fix[x][i][j]; } } int tricicle = 0; for(int i = 0; i < 3; i++){ for(int j = i+1; j < 3; j++){ int can = min(totfix[i][j],totfix[j][i]); resp+=can; totfix[i][j]-=can; totfix[j][i]-=can; tricicle+=totfix[i][j]+totfix[j][i]; } } resp+=tricicle/3*2; return resp; }
#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...