제출 #480832

#제출 시각아이디문제언어결과실행 시간메모리
480832PoPularPlusPlusMutating DNA (IOI21_dna)C++17
0 / 100
46 ms3176 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pb(e) push_back(e) #define sv(a) sort(a.begin(),a.end()) #define sa(a,n) sort(a,a+n) #define mp(a,b) make_pair(a,b) #define vf first #define vs second #define ar array #define all(x) x.begin(),x.end() const int inf = 0x3f3f3f3f; const int mod = 1000000007; const double PI=3.14159265358979323846264338327950288419716939937510582097494459230; bool remender(ll a , ll b){return a%b;} const int N = 100002; string a,b; int cnt[N] , cnt1[N]; bool b1; void init(std::string aa, std::string bb) { a = aa; b = bb; b1 = 1; int n = a.size(); for(int i = 0; i < n; i++){ if(a[i]=='C' || b[i]=='C')b1 = 0; } for(int i = 0; i < n; i++){ cnt[i] = 0; cnt1[i] = 0; if(i){cnt[i] = cnt[i-1];cnt1[i] = cnt1[i-1];} if(a[i] != b[i]){ if(a[i] == 'A')cnt[i]++; else cnt1[i]++; } } } int get_distance(int x, int y) { if(b1 == 1){ int n1 = 0 , n2 = 0 , n3 = 0; int t1 = 0, t2 = 0, t3 = 0; for(int i = x; i <= y; i++){ if(a[i]!=b[i]){ if(a[i] == 'A')t1++; else if(a[i] == 'T')t2++; else t3++; if(b[i] == 'A')n1++; else if(b[i] == 'T')n2++; else n3++; } } if(n1 == t1 && n2 == t2 && n3 == t3){ int c = n1 + n2 + n3; if(c == 3)return 2; if(c == 0)return 0; return 1; } return -1; } int ans = cnt[y]; int ans1 = cnt1[y]; if(x-1 >= 0){ans -= cnt[x-1];ans1-=cnt1[x-1];} if(ans == ans1){ return ans; } else return -1; }
#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...