Submission #1034446

#TimeUsernameProblemLanguageResultExecution timeMemory
1034446hotboy2703Mutating DNA (IOI21_dna)C++17
100 / 100
50 ms11048 KiB
#include "dna.h" #include<bits/stdc++.h> using ll = long long; using namespace std; #define pll pair <ll,ll> #define fi first #define se second #define MP make_pair #define sz(a) (ll((a).size())) #define MASK(i) (1LL<<(i)) #define BIT(mask,i) (((mask) >> (i))&1) ll cnt[100100][3][3]; ll cv(char x){ if (x=='A')return 0; if (x=='C')return 1; return 2; } void init(std::string a, std::string b) { ll n = sz(a); for (ll i = 0;i < n;i ++){ if (i)for (ll j = 0;j < 3;j ++)for (ll k = 0;k < 3;k ++)cnt[i][j][k] = cnt[i-1][j][k]; cnt[i][cv(a[i])][cv(b[i])]++; } } int get_distance(int x, int y) { ll tmp[3][3]; for (ll i = 0;i < 3;i ++)for (ll j = 0;j < 3;j ++){ tmp[i][j] = cnt[y][i][j]; if (x)tmp[i][j] -= cnt[x-1][i][j]; } for (ll i = 0;i < 3;i ++){ if (tmp[i][0] + tmp[i][1] + tmp[i][2] != tmp[0][i] + tmp[1][i] + tmp[2][i])return -1; } ll res = 0; res += min(tmp[0][2],tmp[2][0]); res += min(tmp[0][1],tmp[1][0]); res += min(tmp[1][2],tmp[2][1]); // cout<<(max(tmp[0][2],tmp[2][0]) - min(tmp[0][2],tmp[2][0]))<<endl; res += (max(tmp[0][2],tmp[2][0]) - min(tmp[0][2],tmp[2][0])) * 2; return res; }
#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...