제출 #589621

#제출 시각아이디문제언어결과실행 시간메모리
589621GabrielDNA 돌연변이 (IOI21_dna)C++17
0 / 100
56 ms8716 KiB
#include "dna.h" #include "bits/stdc++.h" using namespace std; vector<int> a1; vector<int> c1; vector<int> t1; vector<int> a2; vector<int> c2; vector<int> t2; vector<int> ac; vector<int> at_; vector<int> ta; vector<int> tc; vector<int> ca; vector<int> ct; vector<int> aa; vector<int> cc; vector<int> tt; void init(string a, string b){ a1.assign(a.size(), 0); c1.assign(a.size(), 0); t1.assign(a.size(), 0); a2.assign(a.size(), 0); c2.assign(a.size(), 0); t2.assign(a.size(), 0); ac.assign(a.size(), 0); at_.assign(a.size(), 0); ta.assign(a.size(), 0); tc.assign(a.size(), 0); ca.assign(a.size(), 0); ct.assign(a.size(), 0); aa.assign(a.size(), 0); cc.assign(a.size(), 0); tt.assign(a.size(), 0); for(int i = 0; i != a.size(); i++){ switch(a[i]){ case 'A': a1[i] = 1; break; case 'C': c1[i] = 1; break; case 'T': t1[i] = 1; } switch(b[i]){ case 'A': a2[i] = 1; break; case 'C': c2[i] = 1; break; case 'T': t2[i] = 1; } if(a[i] == 'A' and b[i] == 'A'){ aa[i] = 1; } if(a[i] == 'C' and b[i] == 'C'){ cc[i] = 1; } if(a[i] == 'T' and b[i] == 'T'){ tt[i] = 1; } if(a[i] == 'A' and b[i] == 'C'){ ac[i] = 1; } if(a[i] == 'A' and b[i] == 'T'){ at_[i] = 1; } if(a[i] == 'T' and b[i] == 'A'){ ta[i] = 1; } if(a[i] == 'T' and b[i] == 'C'){ tc[i] = 1; } if(a[i] == 'C' and b[i] == 'A'){ ca[i] = 1; } if(a[i] == 'C' and b[i] == 'T'){ ct[i] = 1; } if(i > 0){ a1[i] += a1[i - 1]; } if(i > 0){ t2[i] += t2[i - 1]; } if(i > 0){ c2[i] += c2[i - 1]; } if(i > 0){ a2[i] += a2[i - 1]; } if(i > 0){ t1[i] += t1[i - 1]; } if(i > 0){ c1[i] += c1[i - 1]; } if(i > 0) ct[i] += ct[i - 1]; if(i > 0) tc[i] += tc[i - 1]; if(i > 0) ca[i] += ca[i - 1]; if(i > 0) ta[i] += ta[i - 1]; if(i > 0) at_[i] += at_[i - 1]; if(i > 0) tt[i] += tt[i - 1]; if(i > 0) ac[i] += ac[i - 1]; if(i > 0) aa[i] += aa[i - 1]; if(i > 0) cc[i] += cc[i - 1]; } /*for(int i = 0; i != a.size(); i++){ cout<<a1[i]<<" "<<c1[i]<<" "<<t1[i]<<" "<<a2[i]<<" "<<c2[i]<<" "<<t2[i]<<" "<<ac[i]<<" "<<at_[i]<<" "<<ca[i]<<" "<<ct[i]<<" "<<ta[i]<<" "<<tc[i]<<" "<<aa[i]<<" "<<cc[i]<<" "<<tt[i]<<" "<<"\n"; }*/ } int get_distance(int x, int y){ int res = 0; int sac = ac[y]; if(x > 0) sac -= ac[x - 1]; int sat = at_[y]; if(x > 0) sat -= at_[x - 1]; int sca = ca[y]; if(x > 0) sca -= ca[x - 1]; int sct = ct[y]; if(x > 0) sct -= ct[x - 1]; int sta = ta[y]; if(x > 0) sta -= ta[x - 1]; int stc = tc[y]; if(x > 0) stc -= tc[x - 1]; res = res + min(sac, sca); res = res + min(stc, sct); res = res + min(sat, sta); if(sac > sca){ sac -= sca; sca = 0; } else { sca -= sac; sac = 0; } if(sct > stc){ sct -= stc; stc = 0; } else { stc -= sct; sct = 0; } if(sta > sat){ sta -= sat; sat = 0; } else { sat -= sta; sta = 0; } if((sat + sta + sct + stc + sca + sac)%3 != 0) return -1; else return res + (((sat + sta + sct + stc + sca + sac)/3) * 2); }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     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...