Submission #953061

#TimeUsernameProblemLanguageResultExecution timeMemory
953061KasymKMutating DNA (IOI21_dna)C++17
0 / 100
23 ms2392 KiB
#include "dna.h" #include "bits/stdc++.h" using namespace std; string s, s2; int n; const int N = 1e5 + 5; int p_a[N] = {0}, p_b[N] = {0}, p_bile[N] = {0}; // hemmesinin icini basda nollayas void init(string a, string b) { s = a; s2 = b; for(int i = 0; i < n; ++i){ p_a[i + 1] = p_a[i]; p_b[i + 1] = p_b[i]; p_bile[i + 1] = p_bile[i]; if(s[i] == 'A') p_a[i + 1]++; if(s2[i] == 'A') p_b[i + 1]++; if(s[i] == s2[i]) p_bile[i + 1]++; } } int get_distance(int x, int y){ int uz_a = p_a[y + 1] - p_a[x], uz_b = p_b[y + 1] - p_b[x]; int uz_bile = p_bile[y + 1] - p_bile[x]; if(uz_a != uz_b) return -1; else{ int ret = (y - x + 1 - uz_bile) >> 1; return ret; } } // int main(){ // cin >> n; // string a, b; // cin >> a >> b; // init(a, b); // int q; // cin >> q; // while(q--){ // int x, y; // cin >> x >> y; // int ans = get_distance(x, y); // cout << ans << "\n"; // } // return 0; // }
#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...