Submission #541291

#TimeUsernameProblemLanguageResultExecution timeMemory
541291AlesL0Mutating DNA (IOI21_dna)C++17
56 / 100
36 ms5300 KiB
#include <iostream> #include <vector> using namespace std; int n; vector <int> a1, a2, t1, t2, c1, c2, f; void init(string a, string b){ n = a.size(); a1.resize(n+1); a2.resize(n+1); t1.resize(n+1); t2.resize(n+1); c1.resize(n+1); c2.resize(n+1); f.resize(n+1); a1[0] = 0; a2[0] = 0; t1[0] = 0; t2[0] = 0; c1[0] = 0; c2[0] = 0; f[0] = 0; for (int i = 0; i < n; i++){ a1[i+1] = a1[i]; a2[i+1] = a2[i]; t1[i+1] = t1[i]; t2[i+1] = t2[i]; c1[i+1] = c1[i]; c2[i+1] = c2[i]; f[i+1] = f[i]; if (a[i] == 'A')a1[i+1]++; else if (a[i] == 'T')t1[i+1]++; else c1[i+1]++; if (b[i] == 'A')a2[i+1]++; else if (b[i] == 'T')t2[i+1]++; else c2[i+1]++; if (a[i] != b[i])f[i+1]++; } } int get_distance(int x, int y){ if (((a1[y+1]-a1[x])==(a2[y+1]-a2[x])) && ((t1[y+1]-t1[x])==(t2[y+1]-t2[x])) && ((c1[y+1]-c1[x])==(c2[y+1]-c2[x]))){ int h = f[y+1]-f[x]; return ((h+h%2)/2); } else return -1; }
#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...