제출 #739205

#제출 시각아이디문제언어결과실행 시간메모리
739205bobthebuilderDNA 돌연변이 (IOI21_dna)C++17
100 / 100
39 ms8608 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; #define sz(x) (int)x.size() #define REP(i,n) for(int i=0;i<n;i++) #define REP1(i,n) for(int i=1;i<=n;i++) #define pb push_back #define lowb(x) (x&(-x)) #define ALL(_x) _x.begin(),_x.end() #define pii pair<int,int> #define f first #define s second #define SORT_UNIQUE(x) sort(ALL(x)),x.erase(unique(ALL(x)),x.end()) #define ll long long #define MNTO(x,y) x=min(x,y) #define MXTO(x,y) x=max(x,y) const int maxn=2e5+5; const int INF=0x3f3f3f3f; #define REP(i,n) for(int i=0;i<n;i++) int to(char c){ if(c=='A') return 0; if(c=='T') return 1; return 2; } int pf[9][maxn]; int cn[3][maxn]; void init(std::string a, std::string b) { int n=sz(a); REP(i,n){ REP(j,3){ cn[j][i+1]=cn[j][i]; } REP(j,9){ pf[j][i+1]=pf[j][i]; } cn[to(a[i])][i+1]++; cn[to(b[i])][i+1]--; if(a[i]!=b[i]) pf[to(a[i])*3+to(b[i])][i+1]++; } } int get_distance(int x, int y) { ++x,++y; REP(j,3){ if(cn[j][x-1]!=cn[j][y]){ return -1; } } int cnt[9]; REP(j,9){ cnt[j]=pf[j][y]-pf[j][x-1]; } int ans=0; REP(i,9){ int a=i/3,b=i%3; int p=b*3+a; if(p<i) continue; int z=min(cnt[i],cnt[p]); ans+=z; cnt[i]-=z,cnt[p]-=z; } int tot=0; REP(i,9) tot+=cnt[i]; return ans+tot/3*2; return ans+tot/3*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...