제출 #465368

#제출 시각아이디문제언어결과실행 시간메모리
465368PetiDNA 돌연변이 (IOI21_dna)C++17
100 / 100
47 ms8576 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std; const int maxn = (int)1e5+1; int index(char c){ if(c == 'A') return 0; if(c == 'C') return 1; return 2; } int parok[maxn][9] = {}, ell[maxn][3] = {}; void init(std::string a, std::string b) { int n = (int)a.size(); for(int i = 0; i < n; i++){ ell[i+1][index(a[i])]++; ell[i+1][index(b[i])]--; parok[i+1][index(a[i]) + index(b[i])*3]++; } for(int i = 1; i <= n; i++){ for(int j = 0; j < 3; j++) ell[i][j] += ell[i-1][j]; for(int j = 0; j < 9; j++) parok[i][j] += parok[i-1][j]; } } int get_distance(int x, int y) { for(int i = 0; i < 3; i++) if(ell[y+1][i] - ell[x][i] != 0) return -1; vector<int> db(9, 0); for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) db[i+j*3] = parok[y+1][i+j*3] - parok[x][i+j*3]; return max(db[3], db[1]) + db[6] + db[7]; }
#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...