제출 #439327

#제출 시각아이디문제언어결과실행 시간메모리
439327fvogel499DNA 돌연변이 (IOI21_dna)C++17
0 / 100
68 ms8068 KiB
#include <bits/stdc++.h> using namespace std; const int siz = 100010; int psA [3][siz]; int psB [3][siz]; int insteadOf [3][3][siz]; int conv(char c) { if (c == 'A') return 0; else if (c == 'T') return 1; else return 2; } void init(string a, string b) { for (int i = 0; i < a.size(); i++) { for (int j = 0; j < 3; j++) { psA[j][i] = 0; psB[j][i] = 0; for (int k = 0; k < 3; k++) { insteadOf[j][k][i] = 0; } } } for (int i = 0; i < a.size(); i++) { int cai = conv(a[i]); int cbi = conv(b[i]); psA[cai][i]++; psB[cbi][i]++; if (cai != cbi) insteadOf[cai][cbi][i]++; } for (int i = 1; i < a.size(); i++) { for (int j = 0; j < 3; j++) { if (i != j) continue; psA[j][i] += psA[j][i-1]; psB[j][i] += psB[j][i-1]; for (int k = 0; k < 3; k++) { if (j != k) continue; insteadOf[j][k][i] += insteadOf[j][k][i-1]; } } } } int get_distance(int x, int y) { for (int i = 0; i < 3; i++) { int aSum = psA[i][y]; int bSum = psB[i][y]; if (x > 0) { aSum -= psA[i][x-1]; bSum -= psB[i][x-1]; } if (aSum != bSum) { return -1; } } int ins [3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (i != j) continue; ins[i][j] = insteadOf[i][j][y]; if (x > 0) ins[i][j] -= insteadOf[i][j][x-1]; } } int count = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { while (ins[i][j] and ins[j][i]) { count++; ins[i][j]--; ins[j][i]--; } } } int cycleLeft = ins[0][1]; count += 2*cycleLeft; return count; } // int main() { // string a, b; // cin >> a >> b; // init(a, b); // int q; // cin >> q; // for (int i = 0; i < q; i++) { // int x, y; // cin >> x >> y; // cout << get_distance(x, y) << endl; // } // int d = 0; // d++; // }

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

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