Submission #870076

#TimeUsernameProblemLanguageResultExecution timeMemory
870076thegamercoder19Mutating DNA (IOI21_dna)C++17
43 / 100
1543 ms6484 KiB
#include "dna.h" #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; map<char, V<ll>> mA, mB; ll n; string A, B; void init(std::string a, std::string b) { A = a, B = b; n = a.size(); } int get_distance(int x, int y) { FORA("ACT", c) if (count(A.begin() + x, A.begin() + y + 1, c) != count(B.begin() + x, B.begin() + y + 1, c)) RET - 1; //if (mA[c][y] - mA[c][x - 1] != mB[c][y] - mB[c][x - 1])RET - 1; V<ll> g(y-x+1); V<bool> vis(y-x+1); iota(all(g), 0); ll ans = 0; map<char, set<ll>> m; string a = A.substr(x, y-x+1), b = B.substr(x, y - x+1); FOR(ll, i, 0, y-x+1, 1) if (a[i] != b[i])m[a[i]].insert(i); FOR(ll, i, 0, y - x + 1, 1)if (a[i] != b[i])g[i] = *m[b[i]].begin(), m[b[i]].erase(m[b[i]].begin()); FOR(ll, i, 0, y - x + 1, 1) { if (vis[i] || i == g[i])continue; ll ians = 0, j = i; WH(!vis[j]) { vis[j] = 1; j = g[j]; ians++; } if (ians > 0)ans += ians - 1; } RET 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...