Submission #694732

#TimeUsernameProblemLanguageResultExecution timeMemory
694732thegamercoder19Mutating DNA (IOI21_dna)C++17
0 / 100
1540 ms2384 KiB
#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; V<pll> pa, pc, pt; V<ll> pf; V<V<ll>> g; V<bool> used; ll res, ia, ic, it, n; map<char, V<ll>> h; string a, b; void dfs(ll u) { used[u] = 1; res++; FORA(g[u], v) {if (used[v])RET; dfs(v); } } void init(std::string a1, std::string b1) { n = a1.size(); a = a1, b = b1; } int get_distance(int x, int y) { x++, y++; ll ans = 0, n1 = y-x+1; g.assign(n1 + 1, {}); used.assign(n1 + 1, {}); h.clear(); string a1 = '$'+a.substr(x, y-1), b1 = '$'+b.substr(x, y-1); for (auto c : { 'A','T','C' }) if (count(all(a1), c) != count(all(b1), c)) return -1; FOR(ll, i, 1, n1 + 1, 1) if (b1[i] != a1[i])h[b1[i]].push_back(i); FOR(ll, i, 1, n1 + 1, 1) { if (b1[i] == a1[i])continue; if (h[a1[i]].size())g[i].push_back(*h[a1[i]].begin()), h[a1[i]].erase(h[a1[i]].begin()); } FOR(ll, i, 1, n1 + 1, 1) { if (!used[i]) { res = 0; dfs(i); ans += max(0LL, res - 1); } } return ans; }
#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...