Submission #731717

#TimeUsernameProblemLanguageResultExecution timeMemory
731717Dipto_DebdipMutating DNA (IOI21_dna)C++17
21 / 100
36 ms3764 KiB
#include "dna.h" #include <bits/stdc++.h> #define ll long long int using namespace std; string aa, bb; void init(std::string a, std::string b) { aa = a, bb = b; } int get_distance(int x, int y) { string a, b; for (ll i = x; i <= y; i++) a += aa[i]; for (ll i = x; i <= y; i++) b += bb[i]; if (x == y) { if (a != b) return -1; return 0; } else if (y - x == 1) { string rev = a; if (a == b) return 0; reverse(rev.begin(), rev.end()); if (rev == b) return 1; else return -1; } else { if (a == b) return 0; else { if (a[0] == b[0]) { string rem1, rem2; rem1 += a[1]; rem1 += a[2]; rem2 += b[1]; rem2 += b[2]; reverse(rem1.begin(), rem1.end()); if (rem1 == rem2) return 1; else return -1; } else if (a[1] == b[1]) { string rem1, rem2; rem1 += a[0]; rem1 += a[2]; rem2 += b[0]; rem2 += b[2]; reverse(rem1.begin(), rem1.end()); if (rem1 == rem2) return 1; else return -1; } else if (a[2] == b[2]) { string rem1, rem2; rem1 += a[0]; rem1 += a[1]; rem2 += b[0]; rem2 += b[1]; reverse(rem1.begin(), rem1.end()); if (rem1 == rem2) return 1; else return -1; } else { vector<char> one, two; for (char ch : a) one.push_back(ch); for (char ch : b) two.push_back(ch); sort(one.begin(), one.end()); sort(two.begin(), two.end()); if (one == two) return 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...