제출 #488131

#제출 시각아이디문제언어결과실행 시간메모리
488131yungyaoDNA 돌연변이 (IOI21_dna)C++17
100 / 100
40 ms6236 KiB
using namespace std; #pragma GCC optimize("Ofast") #include <iostream> #include <algorithm> #include <vector> #include <utility> #include <stack> #include <queue> #include <set> #include <map> typedef long long LL; typedef pair<int,int> pii; #define F first #define S second #define pb push_back #define mkp make_pair #define iter(x) x.begin() x.end() #define REP(n) for (int __=n;__--;) #define REP0(i,n) for (int i=0;i<n;++i) #define REP1(i,n) for (int i=1;i<=n;++i) const int maxn = 1e5+10,mod = 0; const LL inf = 0; int pre[maxn][6]; void init(string a,string b){ const int n = a.size(); REP0(i,n){ if (a[i] == 'A'){ if (b[i] == 'C') ++pre[i+1][0]; else if (b[i] == 'T') ++pre[i+1][4]; } else if (a[i] == 'C'){ if (b[i] == 'A') ++pre[i+1][3]; else if (b[i] == 'T') ++pre[i+1][2]; } else{ if (b[i] == 'A') ++pre[i+1][1]; else if (b[i] == 'C') ++pre[i+1][5]; } REP0(j,6) pre[i+1][j] += pre[i][j]; } } int get_distance(int x, int y){ int ans[6]; REP0(i,6) ans[i] = pre[y+1][i] - pre[x][i]; int cnt = 0; REP0(i,3){ int m = min(ans[i],ans[i+3]); cnt += m; ans[i] -= m; ans[i+3] -= m; } if (ans[0] == ans[1] and ans[1] == ans[2]) cnt += ans[0]*2; else return -1; if (ans[3] == ans[4] and ans[4] == ans[5]) cnt += ans[3]*2; else return -1; return cnt; }
#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...