제출 #955106

#제출 시각아이디문제언어결과실행 시간메모리
955106IUA_HasinDNA 돌연변이 (IOI21_dna)C++17
35 / 100
29 ms9296 KiB
#include <bits/stdc++.h> #define endl "\n" #define finp for(int i=0; i<n; i++) #define fknp for(int k=0; k<n; k++) #define yeap cout<<"YES"<<endl #define nope cout<<"NO"<<endl #define inpintn int n; cin>>n #define inpintarrn int arr[n]; for(int i=0; i<n; i++){cin>>arr[i];} #define inpllarrn long long arr[n]; for(int i=0; i<n; i++){cin>>arr[i];} #define ll long long using namespace std; #include "dna.h" ll const N = 1e5+10; string aa, bb; ll arra[N], arrc[N], arrt[N]; ll brra[N], brrc[N], brrt[N]; ll diff[N]; void init(std::string a, std::string b) { aa = a; bb = b; ll siz = a.size(); for(int i=0; i<siz; i++){ if(a[i]=='A'){ arra[i+1] = arra[i]+1; arrc[i+1] = arrc[i]; arrt[i+1] = arrt[i]; } else if(a[i]=='C'){ arra[i+1] = arra[i]; arrc[i+1] = arrc[i]+1; arrt[i+1] = arrt[i]; } else { arra[i+1] = arra[i]; arrc[i+1] = arrc[i]; arrt[i+1] = arrt[i]+1; } if(b[i]=='A'){ brra[i+1] = brra[i]+1; brrc[i+1] = brrc[i]; brrt[i+1] = brrt[i]; } else if(b[i]=='C'){ brra[i+1] = brra[i]; brrc[i+1] = brrc[i]+1; brrt[i+1] = brrt[i]; } else { brra[i+1] = brra[i]; brrc[i+1] = brrc[i]; brrt[i+1] = brrt[i]+1; } } for(int i=0; i<siz; i++){ char p = aa[i]; char q = bb[i]; if(p!=q){ diff[i+1] = diff[i]+1; } else { diff[i+1] = diff[i]; } } } int get_distance(int x, int y) { x = x+1; y = y+1; // ll siz1 = aa.size(); // ll diff[siz1+1]; // diff[0] = 0; // for(int i=0; i<siz1; i++){ // char p = aa[i]; // char q = bb[i]; // if(p!=q){ // diff[i+1] = diff[i]+1; // } else { // diff[i+1] = diff[i]; // } // } ll xa = arra[y]-arra[x-1]; ll xc = arrc[y]-arrc[x-1]; ll xt = arrt[y]-arrt[x-1]; ll ya = brra[y]-brra[x-1]; ll yc = brrc[y]-brrc[x-1]; ll yt = brrt[y]-brrt[x-1]; ll d = diff[y]-diff[x-1]; if(xa==ya && xc==yc && xt==yt){ ll ans = d/2; 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...