Submission #741966

# Submission time Handle Problem Language Result Execution time Memory
741966 2023-05-15T08:58:26 Z Evirir Mutating DNA (IOI21_dna) C++17
0 / 100
45 ms 9164 KB
#include "dna.h"

#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
typedef long long ll;

const ll INF = ll(1e18);
const int MAXN = 100005;

const unordered_map<string, int> smap{
	{"AT", 0}, {"TA", 1},
	{"AC", 2}, {"CA", 3},
	{"TC", 4}, {"CT", 5}};

int n;
string s,t;
vector<vector<int>> pre;

void init(string a, string b)
{
	n = sz(a);
	s = a;
	t = b;
	pre.resize(n, vector<int>(6, 0));
	forn(i,0,n)
	{
		string cur;
		cur.pb(s[i]);
		cur.pb(t[i]);
		if (s[i] == t[i]) continue;
		int id = smap.find(cur)->second;
		pre[i][id]++;

		if (i > 0)
		{
			forn(j,0,6) pre[i][j] += pre[i-1][j];
		}
	}
}

vector<int> GetSum(int l, int r)
{
	vector<int> res(6);
	forn(j,0,6)
	{
		res[j] = pre[r][j] - (l > 0 ? pre[l - 1][j] : 0);
	}
	return res;
}

int get_distance(int l, int r)
{
	vector<int> cnt = GetSum(l, r);
	int ans = 0;
	for (int i = 0; i < 6; i += 2)
	{
		int c = min(cnt[i], cnt[i + 1]);
		ans += c;
		cnt[i] -= c;
		cnt[i + 1] -= c;
	}
	vector<int> v;
	for (const int x : cnt) if (x > 0) v.pb(x);
	if (!v.empty())
	{
		if (sz(v) == 3 && v[0] == v[1] && v[1] == v[2])
		{
			ans += v[0] * 2;
		}
		else
		{
			return -1;
		}
	}

	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 9164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 9164 KB Output isn't correct
2 Halted 0 ms 0 KB -