Submission #739204

#TimeUsernameProblemLanguageResultExecution timeMemory
739204bobthebuilderMutating DNA (IOI21_dna)C++17
71 / 100
1582 ms2420 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; string a,b; #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; } void init(std::string A, std::string B) { a=A,b=B; } int get_distance(int x, int y) { int c[3]={0,0,0}; int cnt[9]; REP(i,9) cnt[i]=0; for(int i=x;i<=y;i++){ c[to(a[i])]++; c[to(b[i])]--; if(a[i]!=b[i]){ cnt[to(a[i])*3+to(b[i])]++; } } REP(i,3){ if(c[i]){ return -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; }
#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...