제출 #623387

#제출 시각아이디문제언어결과실행 시간메모리
623387RaedDNA 돌연변이 (IOI21_dna)C++17
0 / 100
403 ms3756 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define ss second #define ff first #define pb push_back #define mk make_pair #define mt make_tuple string X,s; void init(string a,string b){ X=a;s=b; } int get_distance(int x,int y){ int l=x,r=y; map<char,int>mp,ms; for(int i=l;i<=r;i++){ mp[X[i]]++; ms[s[i]]++; } for(int i=0;i<26;i++){ if(mp[i]!=ms[i]){ return -1; } } vector<int>aC,aT,tC,cT,tA,cA; for(int i=l;i<=r;i++){ if(s[i]=='A'&&X[i]=='C'){ aC.pb(i); } if(s[i]=='A'&&X[i]=='T'){ aT.pb(i); } if(s[i]=='T'&&X[i]=='C'){ tC.pb(i); } if(s[i]=='T'&&X[i]=='A'){ tA.pb(i); } if(s[i]=='C'&&X[i]=='T'){ cT.pb(i); } if(s[i]=='C'&&X[i]=='A'){ cA.pb(i); } } int ans=0; for(int i=l;i<=r;i++){ if(s[i]=='A'&&X[i]=='C'&&cA.size()>0){ swap(X[cA.size()-1],X[i]); ans++; cA.pop_back(); } if(s[i]=='A'&&X[i]=='T'&&tA.size()>0){ swap(X[tA.size()-1],X[i]); ans++; tA.pop_back(); } if(s[i]=='T'&&X[i]=='C'&&cT.size()>0){ swap(X[cT.size()-1],X[i]); ans++; cT.pop_back(); } if(s[i]=='T'&&X[i]=='A'&&aT.size()>0){ swap(X[aT.size()-1],X[i]); ans++; aT.pop_back(); } if(s[i]=='C'&&X[i]=='T'&&tC.size()>0){ swap(X[tC.size()-1],X[i]); ans++; tC.pop_back(); } if(s[i]=='C'&&X[i]=='A'&&aC.size()>0){ swap(X[aC.size()-1],X[i]); ans++; aC.pop_back(); } } int o=0; for(int i=l;i<=r;i++){ if(X[i]!=s[i]){ o++; } } ans+=o/3*2; 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...