제출 #823675

#제출 시각아이디문제언어결과실행 시간메모리
823675SoulKnightDNA 돌연변이 (IOI21_dna)C++17
21 / 100
144 ms5056 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ln '\n' const int N = 1e5 + 5; int same[N]; int n; vector<int> wa[3], wb[3]; void init(std::string a, std::string b) { n = a.size(); for (int i = 0; i < n; i++) same[i] = (a[i] == b[i]); for (int i = 0; i < n; i++) same[i] += same[i-1]; for (int i = 0; i < n; i++){ if (a[i] == 'A') wa[0].push_back(i); else if (a[i] == 'C') wa[1].push_back(i); else wa[2].push_back(i); } for (int i = 0; i < n; i++){ if (b[i] == 'A') wb[0].push_back(i); else if (b[i] == 'C') wb[1].push_back(i); else wb[2].push_back(i); } } int get_distance(int x, int y) { bool ok = true; for (int i = 0; i < 3; i++){ int c1 = upper_bound(wa[i].begin(), wa[i].end(), y) - lower_bound(wa[i].begin(), wa[i].end(), x); int c2 = upper_bound(wb[i].begin(), wb[i].end(), y) - lower_bound(wb[i].begin(), wb[i].end(), x); if (c1 != c2) {ok = false; break;} } if (!ok) return -1; return max(0, y-x- (same[y] - ((x-1 < 0)? 0: same[x-1]))); }
#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...