제출 #583665

#제출 시각아이디문제언어결과실행 시간메모리
583665CauchicoDNA 돌연변이 (IOI21_dna)C++17
100 / 100
50 ms6152 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; vector<array<int,6>> arr; //ac,at,ca,ct,ta,tc void init(string a, string b) { n = a.size(); arr.resize(n+1); for (int i=0;i<n;i++) { arr[i+1] = arr[i]; if (a[i] == 'A') { if (b[i] == 'C') { arr[i+1][0]++; } if (b[i] == 'T') { arr[i+1][1]++; } } if (a[i] == 'C') { if (b[i] == 'A') { arr[i+1][2]++; } if (b[i] == 'T') { arr[i+1][3]++; } } if (a[i] == 'T') { if (b[i] == 'A') { arr[i+1][4]++; } if (b[i] == 'C') { arr[i+1][5]++; } } } } int get_distance(int x, int y) { y++; int aa = arr[y][0] + arr[y][1] - arr[x][0] - arr[x][1]; int ab = arr[y][2] + arr[y][4] - arr[x][2] - arr[x][4]; int ca = arr[y][2] + arr[y][3] - arr[x][2] - arr[x][3]; int cb = arr[y][0] + arr[y][5] - arr[x][0] - arr[x][5]; int ta = arr[y][4] + arr[y][5] - arr[x][4] - arr[x][5]; int tb = arr[y][1] + arr[y][3] - arr[x][1] - arr[x][3]; if (aa-ab != 0 or ca-cb != 0 or ta-tb != 0) { return -1; } array<int,6> diff; for (int i=0;i<6;i++) { diff[i] = arr[y][i] - arr[x][i]; } int ans = min(diff[0],diff[2])+min(diff[1],diff[4])+min(diff[3],diff[5]); int uni = abs(diff[0]-diff[2])+abs(diff[1]-diff[4])+abs(diff[3]-diff[5]); return ans + 2*uni/3; }
#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...