Submission #1048347

#TimeUsernameProblemLanguageResultExecution timeMemory
1048347amirhoseinfar1385Mutating DNA (IOI21_dna)C++17
71 / 100
1566 ms3100 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; const int maxn=100000+10; int n,alla[maxn],allb[maxn]; void init(std::string a, std::string b) { n=(int)a.size(); for(int i=0;i<n;i++){ if(a[i]=='A'){ alla[i]=0; }else if(a[i]=='T'){ alla[i]=1; }else{ alla[i]=2; } if(b[i]=='A'){ allb[i]=0; }else if(b[i]=='T'){ allb[i]=1; }else{ allb[i]=2; } } } int get_distance(int x, int y) { vector<int>cnta(3),cntb(3); vector<vector<int>>cnt(3,vector<int>(3)); for(int i=x;i<=y;i++){ cnta[alla[i]]++; cntb[allb[i]]++; cnt[alla[i]][allb[i]]++; } if(cnta!=cntb){ return -1; } int res=min(cnt[0][1],cnt[1][0])+min(cnt[0][2],cnt[2][0])+min(cnt[1][2],cnt[2][1]); cnt[0][1]=max(cnt[0][1],cnt[1][0])-min(cnt[0][1],cnt[1][0]); cnt[0][2]=max(cnt[0][2],cnt[2][0])-min(cnt[0][2],cnt[2][0]); cnt[1][2]=max(cnt[1][2],cnt[2][1])-min(cnt[1][2],cnt[2][1]); res+=((cnt[0][1]+cnt[0][2]+cnt[1][2])/3)*2; return res; }
#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...