제출 #1141984

#제출 시각아이디문제언어결과실행 시간메모리
1141984rayankDNA 돌연변이 (IOI21_dna)C++20
0 / 100
1595 ms2368 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; string A; string B; void init(string a, string b) { A = a; B = b; } int find_pos(char c, string s, int start, int end){ for(int i = start; i <= end; i++){ if(s[i] == c){ return i; } } return -1; } int get_distance(int x, int y) { int res = 0; string suba = A.substr(x, y); string subb = B.substr(x,y); string subacopy = suba; string subbcopy = subb; sort(subacopy.begin(), subacopy.end()); sort(subbcopy.begin(), subbcopy.end()); if(subbcopy != subacopy){ return -1; } while(suba != subb){ for(int i=0; i <suba.size();i++){ if(suba[i] == subb[i]) continue; int pos = find_pos(suba[i], subb, 0, y-x+1); if(pos == -1) return -1; swap(suba[i], suba[pos]); res++; } } return res; }
#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...