제출 #625318

#제출 시각아이디문제언어결과실행 시간메모리
625318joleDNA 돌연변이 (IOI21_dna)C++17
0 / 100
29 ms4236 KiB
#include <iostream> #include <vector> using namespace std; struct Entry { int at, ac, tc; }; vector<Entry> A; void init(string X, string Y) { int N = X.size(); A.clear(); A.reserve(N); for(int i = 0; i < N; ++i) { char x = X[i]; char y = Y[i]; int at = (x == 'A' && y == 'T') - (x == 'T' && y == 'A'); int ac = (x == 'A' && y == 'C') - (x == 'C' && y == 'A'); int tc = (x == 'T' && y == 'C') - (x == 'C' && y == 'T'); if(i > 0) { Entry e = A[i-1]; at += e.at; ac += e.ac; tc += e.tc; } A[i] = Entry { at, ac, tc }; } } int get_distance(int x, int y) { Entry a = A[x]; Entry b = A[y]; int at = b.at - a.at; int ac = b.ac - a.ac; int tc = b.tc - a.tc; // AT -> AT // TC -> CT // we can swap AT with TC to get AC int remaining = abs(at) + abs(ac) + abs(tc); int swaps = (y - x + 1) - remaining; if(at == tc) { int swapped = abs(at); ac += at; at = 0; tc = 0; // changes if(ac != 0) { return -1; } swaps += swapped; } return swaps; }
#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...