제출 #623826

#제출 시각아이디문제언어결과실행 시간메모리
623826a_aguiloDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; vector<vector<int>> tree; int n; //type [0] = A vs T //type [1] = T vs A //type [2] = C vs T //type [3] = T vs C //type [4] = A vs C //type [5] = C vs A void buildTree (int node, int left, int right, vector<vector<int>>& arr){ if(left > right) return; if(left == right){ tree[node] = arr[left]; return; } int mid = left + (right - left)/2; buildTree(2*node, left, mid, arr); buildTree(2*node+1, mid+1, right, arr); tree[node][0] = tree[2*node][0] + tree[2*node+1][0]; tree[node][1] = tree[2*node][1] + tree[2*node+1][1]; } vector<int> getValue (int node, int left, int right, int x, int y){ if(x > right or y < left) return 0; if(x <= left and y >= right) return tree[node]; int mid = left + (right - left)/2; vector<int> l = getValue(2*node, left, mid, x, y); vector<int> r = getValue(2*node+1, mid+1, right, x, y); vector<int> ans = {l[0] + r[0], l[1] + r[1]}; return ans; } void init(string a, string b) { n = a.size(); vector<vector<int>> arr(a.size(), vector<int>(2, 0)); for (int i = 0; i < a.size(); ++i){ if(a[i] != b[i]){ if(a[i] == 'A' and b[i] == 'T') arr[i][0] = 1; if(a[i] == 'T' and b[i] == 'A') arr[i][1] = 1; } } tree = vector<vector<int>> (4*a.size(), vector<int>(2, 0)); buildTree(1, 0, a.size()-1, arr); } int get_distance(int x, int y) { vector<int> ans = getValue(1, 0, n-1, x, y); int resp = 0; int AT = ans[0]; int TA = ans[1]; if(AT == TA) return AT; else return -1; }

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

dna.cpp: In function 'std::vector<int> getValue(int, int, int, int, int)':
dna.cpp:30:38: error: could not convert '0' from 'int' to 'std::vector<int>'
   30 |     if(x > right or y < left) return 0;
      |                                      ^
      |                                      |
      |                                      int
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int i = 0; i < a.size(); ++i){
      |                     ~~^~~~~~~~~~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:54:6: warning: unused variable 'resp' [-Wunused-variable]
   54 |  int resp = 0;
      |      ^~~~