제출 #478765

#제출 시각아이디문제언어결과실행 시간메모리
478765imas_713_aDNA 돌연변이 (IOI21_dna)C++17
100 / 100
62 ms8640 KiB
# include <bits/stdc++.h> #include "dna.h" using namespace std; # define ll long long # define ld long double # define ull unsigned ll # define pll pair<ll,ll> # define pb push_back # define pob pop_back # define mp make_pair # define fi first # define se second # define all(x) x.begin(),x.end() # define rall(x) x.rbegin(),x.rend() # define ts to_string # define ti(a) atoi(a.c_str()) # define NumAfterDecimalP(x) cout<<setprecision(x)<<fixed # define lb lower_bound # define ub upper_bound const ld pi = 2*acos(0.0); const ll inf = LLONG_MAX; const ll mod = 1e9+7; //998244353; const ll sz=100005; struct ss{ ll at,ac,ca,ct,ta,tc; }; vector<ss>k(100005); void init(std::string a, std::string b) { ll s=a.size(); for(int i=0; i<s; i++){ k[i].at=0; k[i].ac=0; k[i].ct=0; k[i].ca=0; k[i].ta=0; k[i].tc=0; } for(int i=1; i<=s; i++){ string p; p+=a[i-1]; p+=b[i-1]; if(p=="AT") k[i].at=k[i-1].at+1; else k[i].at=k[i-1].at; if(p=="AC") k[i].ac=k[i-1].ac+1; else k[i].ac=k[i-1].ac; if(p=="TA") k[i].ta=k[i-1].ta+1; else k[i].ta=k[i-1].ta; if(p=="TC") k[i].tc=k[i-1].tc+1; else k[i].tc=k[i-1].tc; if(p=="CA") k[i].ca=k[i-1].ca+1; else k[i].ca=k[i-1].ca; if(p=="CT") k[i].ct=k[i-1].ct+1; else k[i].ct=k[i-1].ct; } } int get_distance(int x, int y) { y++; ll at=k[y].at-k[x].at; ll ac=k[y].ac-k[x].ac; ll ta=k[y].ta-k[x].ta; ll tc=k[y].tc-k[x].tc; ll ct=k[y].ct-k[x].ct; ll ca=k[y].ca-k[x].ca; if(((at+ac)!=(ta+ca)) || ((ta+tc)!=(at+ct)) || ((ca+ct)!=(ac+tc))) return -1; ll ans=min(at,ta)+min(ca,ac)+min(ct,tc); ll jk[3]; jk[0]=min(ac,ca); jk[1]=min(at,ta); jk[2]=min(tc,ct); ac-=jk[0]; ca-=jk[0]; at-=jk[1]; ta-=jk[1]; ct-=jk[2]; tc-=jk[2]; ans+=2*(ac+ca); 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...