제출 #623818

#제출 시각아이디문제언어결과실행 시간메모리
623818a_aguiloDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; vector<int> tree; int n; void buildTree (int node, int left, int right, 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] = tree[2*node] + tree[2*node+1]; } 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; return getValue(2*node, left, mid, x, y)+getValue(2*node+1, mid+1, right, x, y); } void init(string a, string b) { n = a.size(); int arr[a.size()]; for (int i = 0; i < a.size(); ++i){ if(a[i] == b[i])arr[i] = 0; else arr[i] = 1; } tree = vector<int> (4*arr.size(), 0); buildTree(1, 0, a.size()-1, arr); } int get_distance(int x, int y) { int n = getValue(1, 0, n-1, x, y); if(n%2 != 0) return -1; else return n/2; }

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

dna.cpp:9:54: error: expected ',' or '...' before 'arr'
    9 | void buildTree (int node, int left, int right, int[] arr){
      |                                                      ^~~
dna.cpp: In function 'void buildTree(int, int, int, int*)':
dna.cpp:12:22: error: 'arr' was not declared in this scope
   12 |         tree[node] = arr[left];
      |                      ^~~
dna.cpp:16:34: error: 'arr' was not declared in this scope
   16 |     buildTree(2*node, left, mid, arr);
      |                                  ^~~
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 0; i < a.size(); ++i){
      |                     ~~^~~~~~~~~~
dna.cpp:35:31: error: request for member 'size' in 'arr', which is of non-class type 'int [(<anonymous> + 1)]'
   35 |     tree = vector<int> (4*arr.size(), 0);
      |                               ^~~~