Submission #965517

#TimeUsernameProblemLanguageResultExecution timeMemory
965517marinalucaMutating DNA (IOI21_dna)C++17
100 / 100
30 ms5468 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O4") #pragma GCC optimize ("fast-math") #pragma GCC optimize ("unroll-loops") using namespace std; //#define int long long #define ll long long #define xx first #define yy second const int NMAX = 1e5; int at[NMAX + 5], t[NMAX + 5], c[NMAX + 5]; int v[NMAX + 5]; string a, b; void init (string as, string bs){ int n = as.length(); a = as; b = bs; for (int i = 1; i <= n; ++ i){ at[i] = at[i - 1]; t[i] = t[i - 1]; c[i] = c[i - 1]; v[i] = v[i - 1]; if (a[i - 1] == b[i - 1]) v[i] ++; else if (a[i - 1] == 'A' && b[i - 1] == 'T') at[i] ++; else if (a[i - 1] == 'T' && b[i - 1] == 'A') at[i] --; else if (a[i - 1] == 'T' && b[i - 1] == 'C') t[i] ++; else if (a[i - 1] == 'C' && b[i - 1] == 'T') t[i] --; else if (a[i - 1] == 'C' && b[i - 1] == 'A') c[i] ++; else c[i] --; } } int get_distance(int x, int y){ y ++; int unu = at[y] - at[x]; int doi = t[y] - t[x]; int trei = c[y] - c[x]; if (unu != doi || unu != trei) return -1; int val = abs (unu) * 2; int ans = y - x; ans -= (v[y] - v[x]); ans -= abs(unu) * 3; val += ans / 2; return val; }
#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...