Submission #1009482

#TimeUsernameProblemLanguageResultExecution timeMemory
1009482somefjordMutating DNA (IOI21_dna)C++17
0 / 100
17 ms3676 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; string as, bs; vector<int> balance1, balance2, misplacecount; void init(string a, string b) { as = a; bs = b; int n = a.length(); balance1.resize(n + 2, 0); balance2.resize(n + 2, 0); misplacecount.resize(n + 2, 0); for (int i = 1; i <= n; ++i) { balance1[i] = balance1[i - 1] + (as[i - 1] == 'A' ? 1 : -1); balance2[i] = balance2[i - 1] + (bs[i - 1] == 'A' ? 1 : -1); misplacecount[i] = misplacecount[i - 1] + (as[i - 1] == 'A' && as[i - 1] != bs[i - 1]); // printf("i : %d, %d %d %d\n", i, acount1[i], acount2[i], // misplacecount[i]); } } int get_distance(int x, int y) { if ((balance1[y] - balance2[x]) != (balance2[y] - balance2[x])) return -1; return misplacecount[y] - misplacecount[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...