제출 #969282

#제출 시각아이디문제언어결과실행 시간메모리
969282androDNA 돌연변이 (IOI21_dna)C++17
0 / 100
43 ms2388 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std; string A, B; void init(std::string a, std::string b) { A = a; B = b; } int get_distance(int x, int y) { map<char,int> M, M1; for(int i = x; i <= y; i++) { M[A[i]] += 1; M1[B[i]] += 1; } if(M['A'] != M1['A'] || M['T'] != M1['T'] || M['C'] != M1['C']) { return - 1; } int ans = 0; for(int i = x; i <= y; i++) { if(A[i] == B[i]) { continue; } int ok = 0; for(int j = i + 1; j <= y; j++) { if(A[i] == B[j] && A[j] == B[i]) { swap(A[i], A[j]); ok = 1; break; } } ans += 1; if(! ok) { for(int j = i + 1; j <= y; j++) { if(B[i] == A[j]) { swap(A[i], A[j]); break; } } } } return ans; } /* int main() { init("ATACAT", "ACTATA"); cout << get_distance(0, 5); }*/
#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...