제출 #594030

#제출 시각아이디문제언어결과실행 시간메모리
594030rc_catuntaDNA 돌연변이 (IOI21_dna)C++17
100 / 100
61 ms9016 KiB
#include "dna.h" #include <algorithm> #include <vector> #include <set> #include <iostream> using namespace std; string sa, sb, a, b; vector<int> A1,A2,T1,T2,C1,C2; vector<int> AC, AT, CA, CT, TA, TC; void init(string a, string b) { sa = a; sb = b; // Construimos la tabla de acumuladas A1.assign(a.size(),0); T1.assign(a.size(),0); C1.assign(a.size(),0); A2.assign(a.size(),0); T2.assign(a.size(),0); C2.assign(a.size(),0); AC.assign(a.size(),0); AT.assign(a.size(),0); CT.assign(a.size(),0); CA.assign(a.size(),0); TA.assign(a.size(),0); TC.assign(a.size(),0); for(int i=0;i<a.size();i++){ if(a[i]=='A') A1[i]++; if(a[i]=='C') C1[i]++; if(a[i]=='T') T1[i]++; if(b[i]=='A') A2[i]++; if(b[i]=='C') C2[i]++; if(b[i]=='T') T2[i]++; if(a[i]=='A' and b[i]=='C') AC[i]++; if(a[i]=='A' and b[i]=='T') AT[i]++; if(a[i]=='C' and b[i]=='T') CT[i]++; if(a[i]=='C' and b[i]=='A') CA[i]++; if(a[i]=='T' and b[i]=='A') TA[i]++; if(a[i]=='T' and b[i]=='C') TC[i]++; if(i>0){ A1[i] += A1[i-1]; A2[i] += A2[i-1]; C1[i] += C1[i-1]; C2[i] += C2[i-1]; T1[i] += T1[i-1]; T2[i] += T2[i-1]; AC[i] += AC[i-1]; AT[i] += AT[i-1]; CT[i] += CT[i-1]; CA[i] += CA[i-1]; TA[i] += TA[i-1]; TC[i] += TC[i-1]; } } } int get_distance(int x, int y) { int res = 0; int ca1 = A1[y]; int cc1 = C1[y]; int ct1 = T1[y]; int ca2 = A2[y]; int cc2 = C2[y]; int ct2 = T2[y]; if(x>0){ ca1 -= A1[x-1]; cc1 -= C1[x-1]; ct1 -= T1[x-1]; ca2 -= A2[x-1]; cc2 -= C2[x-1]; ct2 -= T2[x-1]; } if(ca1 == ca2 and cc1 == cc2 and ct1 == ct2){ // Se puede int cac = AC[y]; int cat = AT[y]; int cct = CT[y]; int cca = CA[y]; int cta = TA[y]; int ctc = TC[y]; if(x>0){ cac -= AC[x-1]; cat -= AT[x-1]; cct -= CT[x-1]; cca -= CA[x-1]; cta -= TA[x-1]; ctc -= TC[x-1]; } //cout<<cac<<" "<<cat<<" "<<cct<<" "<<cca<<" "<<cta<<" "<<ctc<<"\n"; // AC con CA int mini = min(cac,cca); res += mini; cac -= mini; cca -= mini; // AT con TA mini = min(cat,cta); res += mini; cat -= mini; cta -= mini; mini = min(cct,ctc); res += mini; cct -= mini; ctc -= mini; int cmdif = ((cac + cca +cat + cta + cct + ctc)/3)*2; res += cmdif; return res; } else return -1; }

컴파일 시 표준 에러 (stderr) 메시지

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:28:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for(int i=0;i<a.size();i++){
      |              ~^~~~~~~~~
#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...