제출 #453802

#제출 시각아이디문제언어결과실행 시간메모리
453802RGBBDNA 돌연변이 (IOI21_dna)C++17
100 / 100
62 ms9740 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; const int MAXN=1e5; int n,psa[MAXN][3][2],diff[MAXN][3][3],temp[3][3]; map<char,int>cmp; int get_distance(int x,int y){ for(int i=0;i<3;i++){ int an=psa[y][i][0]-(x!=0?psa[x-1][i][0]:0); int bn=psa[y][i][1]-(x!=0?psa[x-1][i][1]:0); if(an!=bn)return -1; } int ret=0; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ temp[i][j]=diff[y][i][j]-(x!=0?diff[x-1][i][j]:0); } } for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ if(i==j)continue; int m=min(temp[i][j],temp[j][i]); ret+=m; temp[i][j]-=m; temp[j][i]-=m; } } int s=0; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ if(i==j)continue; s+=temp[i][j]; } } s*=2; s/=3; ret+=s; return ret; } void init(string a,string b){ n=a.length(); cmp['A']=0; cmp['T']=1; cmp['C']=2; for(int i=0;i<n;i++){ if(i!=0){ for(int j=0;j<3;j++){ for(int k=0;k<2;k++){ psa[i][j][k]=psa[i-1][j][k]; } } for(int j=0;j<3;j++){ for(int k=0;k<3;k++){ diff[i][j][k]=diff[i-1][j][k]; } } } psa[i][cmp[a[i]]][0]++; psa[i][cmp[b[i]]][1]++; diff[i][cmp[a[i]]][cmp[b[i]]]++; } }
#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...