제출 #958345

#제출 시각아이디문제언어결과실행 시간메모리
958345AC2KDNA 돌연변이 (IOI21_dna)C++17
56 / 100
28 ms10788 KiB
#include "dna.h" #include <bits/stdc++.h> #include <vector> using namespace std; int sum[300000]; int suma[3][300000], sumb[3][300000]; const string dna = "ATC"; void init(std::string a, std::string b) { memset(sum, 0, sizeof(sum)); memset(suma, 0, sizeof(suma)); memset(suma, 0, sizeof(sumb)); for (int i = 0; i < (int)a.size(); ++i) { sum[i + 1] = sum[i] + (a[i] != b[i]); } for (int j = 0; j < 3; ++j) { for (int i = 0; i < (int)a.size(); ++i) { suma[j][i + 1] = suma[j][i] + (a[i] == dna[j]); sumb[j][i + 1] = sumb[j][i] + (b[i] == dna[j]); } } } int get_distance(int x, int y) { ++y; for (int i = 0; i < 3; ++i) { if (suma[i][y] - suma[i][x] != sumb[i][y] - sumb[i][x]) { return -1; } } return (sum[y] - sum[x] + 1) / 2; }
#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...