Submission #437337

#TimeUsernameProblemLanguageResultExecution timeMemory
437337Mohammed_AtalahMutating DNA (IOI21_dna)C++17
56 / 100
80 ms8040 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; vector<int64_t> T1; vector<int64_t> T2; vector<int64_t> A1; vector<int64_t> A2; vector<int64_t> C1; vector<int64_t> C2; vector<int64_t> same; void init(std::string a, std::string b) { int64_t len = a.size(); T1.resize(len+1); T2.resize(len+1); A1.resize(len+1); A2.resize(len+1); C1.resize(len+1); C2.resize(len+1); same.resize(len+1); int64_t currA1 = 0; int64_t currT1 = 0; int64_t currA2 = 0; int64_t currT2 = 0; int64_t currC1 = 0; int64_t currC2 = 0; int64_t currsame = 0; for(int i = 0; i < len; i++){ if(a[i] == 'A'){ currA1++; }else if(a[i] == 'T'){ currT1++; }else if(a[i] == 'C'){ currC1++; } if(b[i] == 'A'){ currA2++; }else if(b[i] == 'T'){ currT2++; }else if(b[i] == 'C'){ currC2++; } if(a[i] == b[i]){ currsame++; } A1[i+1] = currA1; T1[i+1] = currT1; A2[i+1] = currA2; T2[i+1] = currT2; C1[i+1] = currC1; C2[i+1] = currC2; same[i+1] = currsame; } } int get_distance(int x, int y) { int64_t a1 = A1[y+1] - A1[x]; int64_t t1 = T1[y+1] - T1[x]; int64_t c1 = C1[y+1] - C1[x]; int64_t a2 = A2[y+1] - A2[x]; int64_t t2 = T2[y+1] - T2[x]; int64_t c2 = C2[y+1] - C2[x]; int64_t s = same[y+1] - same[x]; // cout << s << endl; if(t1 != t2 || a1 != a2 || c1 != c2){ // cout << t1 << " " << t2 << endl; // cout << a1 << " " << a2 << endl; // cout << c1 << " " << c2 << endl; return -1; } return ceil((((y-x)+1 ) - s )/ 2.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...