제출 #1033483

#제출 시각아이디문제언어결과실행 시간메모리
1033483PokemonMasterDNA 돌연변이 (IOI21_dna)C++17
0 / 100
15 ms5148 KiB
#include<bits/stdc++.h> #include "dna.h" using namespace std; string a,b; int n; void init(std::string a, std::string b) { cin>>a>>b; } int get_distance(int x, int y) { string na="",nb=""; map <char,int> mp1,mp2; for(int i=x;i<=y;i++) { na+=a[i]; nb+=b[i]; } string ca=na,cb=nb; sort(ca.begin(),ca.end()); sort(cb.begin(),cb.end()); if(ca!=cb) { return -1; } int cnt=0,res=0; while(na!=nb) { int ind=0; for(int j=cnt;j<=n;j++) { if(na[j]==nb[cnt]) { ind=j; break; } } while(ind!=cnt) { swap(na[ind],na[ind-1]); ind--; res++; } cnt++; } 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...