제출 #1060338

#제출 시각아이디문제언어결과실행 시간메모리
1060338tolbiDNA 돌연변이 (IOI21_dna)C++17
0 / 100
22 ms5908 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; vector<array<int,6>> pref; void init(std::string a, std::string b) { pref.resize(a.length()+1,array<int,6>()); for (int i = 0; i < a.length(); i++){ if (a[i]=='A' && b[i]=='C') pref[i+1][0]=1; if (a[i]=='A' && b[i]=='T') pref[i+1][1]=1; if (a[i]=='T' && b[i]=='A') pref[i+1][2]=1; if (a[i]=='T' && b[i]=='C') pref[i+1][3]=1; if (a[i]=='C' && b[i]=='A') pref[i+1][4]=1; if (a[i]=='C' && b[i]=='T') pref[i+1][5]=1; for (int j = 0; j < 6; j++){ pref[i+1][j]+=pref[i][j]; } } } int get_distance(int x, int y) { int ac = pref[y+1][0]-pref[x][0]; int at = pref[y+1][1]-pref[x][1]; int ta = pref[y+1][2]-pref[x][2]; int tc = pref[y+1][3]-pref[x][3]; int ca = pref[y+1][4]-pref[x][4]; int ct = pref[y+1][5]-pref[x][5]; int ans = min(ac,ca)+min(tc,ct)+min(at,ta); if (ac>ca){ ac-=ca; ca=0; } else { ca-=ac; ac=0; } if (ct>tc){ ct-=tc; tc=0; } else { tc-=ct; ct=0; } if (at>ta){ at-=ta; ta=0; } else { ta-=at; at=0; } if (ac>0){ if (ac!=ct || ct!=ta) return -1; return ans+ac*2; } else { if (ca!=at || tc!=ca) return -1; return ans+ca*2; } }

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

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