# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
696122 | thegamercoder19 | Mutating DNA (IOI21_dna) | C++17 | 48 ms | 3744 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dna.h"
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
#define FILER 0
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = pow(10, 9) + 7;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const ull INFUL = 0x3f3f3f3f3f3f3f3f;
const ll INFT = 0x3f3f3f3f;
const ull MAX = 1LL << 24;
const ll MODD = 998244353;
const double EPS = 1e-10;
#define V vector
#define pll pair<ll, ll>
#define pull2 pair<ull,ull>
#define MS multiset
#define M map
#define Q queue
#define PQ priority_queue
#define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c)
#define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c)
#define FORA(a,i) for(auto &i : a)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define sorta(a) sort(all(a))
#define sortd(a) sort(all(a), greater<ll>())
#define setp(x) setprecision(x)<<fixed
#define RET return
#define log(a,b) log(b)/log(a)
#define WH(s) while(s)
#define WHI(t) WH(t--)
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define YESNO(s) cout << (s ? "YES" : "NO") << endl;
#define YesNo(s) cout<<(s?"Yes":"No")<<endl;
#define TYP 0
using namespace std;
string a, b;
ll n, ans;
V<bool> used;
map<char, V<ll>> h;
V<pll> g;
void dfs(ll u)
{
used[u] = 1;
ans++;
if (!used[g[u].second])dfs(g[u].second);
}
void init(std::string a1, std::string b1)
{
a = '$' + a1, b = '$' + b1;
}
int get_distance(int x, int y)
{
x++, y++;
ll res = 0;
string a1 = "$", b1 = a1;
FOR(ll, i, x, y + 1, 1)a1 += a[i], b1 += b[i];
if (count(all(a1), 'A') != count(all(b1), 'A')) return -1;
if (count(all(a1), 'T') != count(all(b1), 'T')) return -1;
if (count(all(a1), 'C') != count(all(b1), 'C')) return -1;
h.clear(); used.assign(a1.size(), 0); g.resize(a1.size(), {});
FOR(ll, i, 1, a1.size(), 1)h[b1[i]].emplace_back(i);
FOR(ll, i, 1, a1.size(), 1)
g[i] = { *h[a1[i]].begin(), i }, h[a1[i]].erase(h[a1[i]].begin());
sort(all(g));
FOR(ll, i, 1, a1.size(), 1)
{
if (used[i] || g[i].second == i) continue;
ans = 0; dfs(i);
res += max(0LL, ans - 1);
}
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |