제출 #550237

#제출 시각아이디문제언어결과실행 시간메모리
550237rafatoaDNA 돌연변이 (IOI21_dna)C++17
21 / 100
38 ms2500 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=i+1; j<n; j++){ if(a[i] != b[i] && a[j] != b[j]){ 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...