Submission #894338

#TimeUsernameProblemLanguageResultExecution timeMemory
894338MalixMutating DNA (IOI21_dna)C++17
100 / 100
41 ms14564 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pi; #define REP(i,a,b) for(int i=a;i<b;i++) #define F first #define S second #define PB push_back #define MP make_pair vector<vi> arr; void init(std::string a, std::string b) { int n=a.size(); vector<vi> s(n,vi(6,0)); REP(i,0,n){ if(a[i]==b[i])continue; if(a[i]=='T'){ if(b[i]=='A')s[i][0]++; if(b[i]=='C')s[i][2]++; } else if(a[i]=='A'){ if(b[i]=='T')s[i][1]++; if(b[i]=='C')s[i][4]++; } else{ if(b[i]=='T')s[i][3]++; if(b[i]=='A')s[i][5]++; } } arr.resize(n,vi(6,0)); REP(i,0,6)arr[0][i]=s[0][i]; REP(i,1,n){ REP(j,0,6)arr[i][j]=arr[i-1][j]+s[i][j]; } } int get_distance(int x, int y) { int ans=0;int t=0; vi arr2(6); if(x==0)REP(i,0,6)arr2[i]=arr[y][i]; else REP(i,0,6)arr2[i]=arr[y][i]-arr[x-1][i]; //REP(i,0,6)cout<<arr2[i]<<" "; REP(i,0,6){ t=min(arr2[i],arr2[i+1]); arr2[i]-=t;arr2[i+1]-=t; ans+=t; i++; } if(arr2[0]==arr2[4]&&arr2[0]==arr2[3])ans+=2*arr2[0]; else return -1; if(arr2[1]==arr2[2]&&arr2[1]==arr2[5])ans+=2*arr2[1]; else return -1; 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...