Submission #1086653

#TimeUsernameProblemLanguageResultExecution timeMemory
1086653IcelastMutating DNA (IOI21_dna)C++17
0 / 100
30 ms7120 KiB
#include "dna.h" #include <iostream> #include <bits/stdc++.h> #define ll long long using namespace std; const ll maxn = 2*1e5+5, INF = 4e18+9; int pf[maxn][3][3]; void init(std::string a, std::string b) { int n = a.size(); a = ' ' + a; b = ' ' + b; map<char, int> mp; mp['A'] = 0; mp['T'] = 1; mp['C'] = 2; for(int i = 1; i <= n; i++){ for(int p = 0; p < 3; p++){ for(int q = 0; q < 3; q++){ pf[i][p][q] = pf[i-1][p][q]; } } int p = mp[a[i]], q = mp[b[i]]; pf[i][p][q]++; } } int get_distance(int x, int y) { x++; y++; vector<vector<int>> d(3, vector<int>(3, 0)); vector<int> cnt(3, 0); for(int p = 0; p < 3; p++){ for(int q = 0; q < 3; q++){ d[p][q] = pf[y][p][q] - pf[x-1][p][q]; cnt[p] += d[p][q]; cnt[q] -= d[p][q]; } } for(int i = 0; i < 3; i++){ if(cnt[i] != 0) return -1; } int ans = 0; for(int p = 0; p < 3; p++){ for(int q = 0; q < p; q++){ int diff = min(d[p][q], d[q][p]); d[p][q] -= diff; d[q][p] -= diff; ans = max(d[p][q], d[q][p]); } } ans*=2; return ans; }
#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...