Submission #1142152

#TimeUsernameProblemLanguageResultExecution timeMemory
1142152mehdibaMutating DNA (IOI21_dna)C++20
0 / 100
19 ms5188 KiB
#include "dna.h" #include <bits/stdc++.h> #define endl '\n' #define pb push_back #define F first #define S second #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), v.rend() using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; string a, b; vector<int> p(1e5), faa(1e5), fta(1e5), fca(1e5), fab(1e5), ftb(1e5), fcb(1e5); void init(string A, string B){ a = A, b = B; int n = a.size(); p[0] = (a[0] != b[0]); for(int i = 1; i < n; i++){ p[i] = p[i - 1] + (a[i] != b[i]); faa[i] = faa[i - 1] + (a[i] == 'A'); fta[i] = fta[i - 1] + (a[i] == 'T'); fca[i] = fca[i - 1] + (a[i] == 'C'); fab[i] = fab[i - 1] + (b[i] == 'A'); ftb[i] = ftb[i - 1] + (b[i] == 'T'); fcb[i] = fcb[i - 1] + (b[i] == 'C'); } } int get_distance(int x, int y){ int cnt = p[y] - (x ? p[x - 1] : 0); int ffaa = faa[y] - faa[x - 1]; int ffat = fta[y] - fta[x - 1]; int ffac = fca[y] - fca[x - 1]; int ffba = fab[y] - fab[x - 1]; int ffbt = ftb[y] - ftb[x - 1]; int ffbc = fcb[y] - fcb[x - 1]; if(cnt % 2 || ffaa != ffba || ffat != ffbt || ffac != ffbc) return -1; return cnt / 2; }
#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...