Submission #1015680

#TimeUsernameProblemLanguageResultExecution timeMemory
1015680jairRSMutating DNA (IOI21_dna)C++17
21 / 100
20 ms3932 KiB
#include "dna.h" #include <bits/stdc++.h> #define all(s) s.begin(), s.end() using namespace std; string a, b; int n; void init(string _a, string _b) { a = _a; b = _b; n = a.size(); } int get_distance(int x, int y) { string sub_a = string(a.begin() + x, a.begin() + y + 1); string sub_b = string(b.begin() + x, b.begin() + y + 1); if (sub_a == sub_b) return 0; // sub_a != sub_b if (sub_a.size() == 1) return -1; if (sub_a.size() == 2) { sort(all(sub_a)); sort(all(sub_b)); if (sub_a != sub_b) return -1; else return 1; } // sub.size() == 3 string oa = sub_a; string ob = sub_b; sort(all(sub_a)); sort(all(sub_b)); if (sub_a != sub_b) return -1; // counts tan bien int eq = 0; for (int i = 0; i < 3; i++) { eq += oa[i] == ob[i]; } switch (eq) { case 0: return 2; case 1: return 1; default: return -2; // explode } }
#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...