Submission #922669

#TimeUsernameProblemLanguageResultExecution timeMemory
922669tvladm2009Mutating DNA (IOI21_dna)C++17
100 / 100
37 ms6936 KiB
#include "dna.h"
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double;
const string FILENAME = "input";
const int MAXN = 100228;

int cnt[MAXN][3][3];

void init(string a, string b) {
	string alf = "ACT";
	for (int i = 1; i <= sz(a); i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				cnt[i][j][k] = cnt[i - 1][j][k] + (a[i - 1] == alf[j] && b[i - 1] == alf[k]);
			}
		}
	}
}

int get_distance(int l, int r) {
	int res = 0, prv = 0;
	for (int i = 0; i < 3; i++) {
		int j = (i + 1) % 3;
		int x = cnt[r + 1][i][j] - cnt[l][i][j];
		int y = cnt[r + 1][j][i] - cnt[l][j][i];
		if (i != 0) {
			if (prv != x - y) {
				return -1;
			}
		} else {
			res += 2 * abs(x - y);
			prv = x - y;
		}
		res += min(x, y);
	}
	return res;
}

/**
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//read(FILENAME);
	
	return 0;
}
**/

#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...