Submission #1179618

#TimeUsernameProblemLanguageResultExecution timeMemory
1179618madamadam3Mutating DNA (IOI21_dna)C++20
0 / 100
18 ms4416 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; int n; string A, B; vi acount[2], tcount[2], ps; void init(string a, string b) { A = a; B = b; n = (int) a.size(); acount[0].assign(n + 1, 0); acount[1].assign(n + 1, 0); tcount[0].assign(n + 1, 0); tcount[1].assign(n + 1, 0); ps.assign(n + 1, 0); for (int i = 0; i < n; i++) { ps[i + 1] = ps[i] + ((a[i] == 'T' && b[i] == 'A') ? 1 : 0); acount[0][i + 1] = acount[0][i] + (a[i] == 'A') ? 1 : 0; acount[1][i + 1] = acount[1][i] + (b[i] == 'A') ? 1 : 0; tcount[0][i + 1] = tcount[0][i] + (a[i] == 'T') ? 1 : 0; tcount[1][i + 1] = tcount[1][i] + (b[i] == 'T') ? 1 : 0; // cout << "a[" << i << "] = " << a[i] << " and b[" << i << "] = " << b[i] << "\n"; // cout << "ps[" << i+1 << "] = " << ps[i+1] << "\n"; // cout << "is there a mismatch? " << ((a[i] == 'T' && b[i] == 'A') ? 1 : 0) << "\n"; } } int get_distance(int x, int y) { if ((acount[0][y + 1] - acount[0][x] != acount[1][y + 1] - acount[1][x]) || (tcount[0][y + 1] - tcount[0][x] != tcount[1][y + 1] - tcount[1][x])) { return -1; } // cout << "ps[y+1] = " << ps[y + 1] << " and ps[x] = " << ps[x] << "\n"; return ps[y + 1] - ps[x]; }
#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...