제출 #437438

#제출 시각아이디문제언어결과실행 시간메모리
437438AdamGSDNA 돌연변이 (IOI21_dna)C++17
100 / 100
60 ms6788 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(a, b) for(int a = 0; a < (b); ++a) #define pb push_back #define st first #define nd second #define all(a) a.begin(), a.end() #define lg(a) (31-__builtin_clz(a)) const int LIM=1e5+7; int A[LIM], B[LIM], sum[LIM][3][3]; int n; void init(string a, string b) { n=a.size(); rep(i, n) { if(a[i]=='T') A[i]=1; else if(a[i]=='C') A[i]=2; if(b[i]=='T') B[i]=1; else if(b[i]=='C') B[i]=2; if(i) { rep(j, 3) rep(k, 3) sum[i][j][k]=sum[i-1][j][k]; } ++sum[i][A[i]][B[i]]; } } int licz(int x, int y, int a, int b) { if(!x) return sum[y][a][b]; return sum[y][a][b]-sum[x-1][a][b]; } int get_distance(int x, int y) { rep(i, 3) { int a=0, b=0; rep(j, 3) { a+=licz(x, y, i, j); b+=licz(x, y, j, i); } if(a!=b) return -1; } int ile[3][3], ans=0, ma=0; rep(i, 3) rep(j, 3) ile[i][j]=licz(x, y, i, j); rep(i, 3) rep(j, i) { int p=min(ile[i][j], ile[j][i]); ans+=p; ile[i][j]-=p; ile[j][i]-=p; ma=max(ma, max(ile[i][j], ile[j][i])); } ans+=2*ma; 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...