Submission #550247

#TimeUsernameProblemLanguageResultExecution timeMemory
550247rafatoaMutating DNA (IOI21_dna)C++17
43 / 100
1597 ms2508 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back string global_a, global_b; void init(string a, string b){ global_a = a; global_b = b; } int get_distance(int x, int y){ int n = y-x+1; string a, b; for(int i=x; i<=y; i++){ a.pb(global_a[i]); b.pb(global_b[i]); } string copy1 = a, copy2 = b; sort(copy1.begin(), copy1.end()); sort(copy2.begin(), copy2.end()); if(copy1 != copy2) return -1; int sum = 0; for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ if(i == j) continue; if(a[i] != b[i] && a[j] != b[j] && b[j] == a[i]){ swap(b[i], b[j]); sum++; } } } return sum; } // int main(){ // init("ATACAT", "ACTATA"); // cout << get_distance(1, 3) << "\n"; // cout << get_distance(4, 5) << "\n"; // cout << get_distance(3, 5) << "\n"; // }
#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...