Submission #466346

#TimeUsernameProblemLanguageResultExecution timeMemory
466346fuad27Mutating DNA (IOI21_dna)C++17
100 / 100
46 ms9480 KiB
#include<bits/stdc++.h>
#include "dna.h"
 
using namespace std;
typedef long long ll;
typedef long double ld;
#define vii vector<pair<int, int>>
#define vi vector<int>
#define vl vector<long long>
#define vll vector<pair<long long, long long>>
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i = a;i<=b;i++)
#define f first
#define s second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
#define start int tt;cin>>tt;rep(testcase, 1, tt)
#define print(k) cout<<"Case #"<<testcase<<": "<<k<<"\n";
#define endl "\n"
#define DEBUG(k) cerr<<k<<"\n";
int t[100010][4][4], n;
int valt(char c) {
    return (c=='A' ? 1 : c=='T' ? 2 : 3);
}
void init(string a, string b) {
    n=a.size();
    for (int i=1; i<=n; i++) {
        int x=valt(a[i-1]), y=valt(b[i-1]);
        for (int j=1; j<=3; j++) {
            for (int k=1; k<=3; k++) {
                t[i][j][k]=t[i-1][j][k];
            }
        }
        t[i][x][y]++;
    }
}
 
int get_distance(int x, int y) {
    	y++;
	int s[4][4];
	for (int i=1; i<=3; i++) {
        for (int j=1; j<=3; j++) {
            s[i][j]=t[y][i][j]-t[x][i][j];
        }
	}
	int a=s[1][2], b=s[2][1], c=s[1][3], d=s[3][1], e=s[2][3], f=s[3][2];
	int ans=0;
	ans+=min(a, b), ans+=min(c, d), ans+=min(e, f);
	if (a-b==e-f && e-f==d-c) {
        ans+=2*abs(a-b);
        return ans;
	}
	return -1;
}
#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...