제출 #986958

#제출 시각아이디문제언어결과실행 시간메모리
986958kachim2DNA 돌연변이 (IOI21_dna)C++17
0 / 100
26 ms5908 KiB
#include "dna.h"
#include <algorithm>
#include <vector>
#include <array>
std::array<std::array<std::vector<int>, 3>, 3> aaa;
std::array<int, 256> chtoi = {};
void init(std::string a, std::string b) {
  chtoi['A'] = 0;
  chtoi['T'] = 1;
  chtoi['C'] = 2;
  for (auto &i : aaa) {
    for (auto &j : i) {
      j.resize(a.size()+1);
      std::fill(j.begin(), j.end(), 0);
    }
  }
  for (int i = 0; i < a.size(); i++) {
      for (auto &A : aaa) {
    for (auto &j : A) {
      j[i+1] = j[i];
    }
      }
      aaa[chtoi[a[i]]][chtoi[b[i]]][i] ++;
  }
}

int get_distance(int x, int y) {
  int ret = 0;
  std::array<std::array<int, 3>, 3> bbb;
  for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (aaa[i][j][y + 1] - aaa[i][j][x] !=
            aaa[j][i][y + 1] - aaa[j][i][x]) {
	  return -1;
        } else {
	  ret+= aaa[i][j][y + 1] - aaa[i][j][x];
        }
  }
  }
  return ret;
}

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

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