제출 #1190037

#제출 시각아이디문제언어결과실행 시간메모리
1190037epicci23트리 (IOI24_tree)C++20
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" #include "tree.h" #define ll long long #define all(v) v.begin() , v.end() #define sz(a) (int)a.size() using namespace std; ll n; vector<ll> p, w; void init(vector<int> P, vector<int> W){ n = sz(P); p.resize(n),w.resize(n); for(int i = 0; i < n; i++){ p[i] = P[i]; w[i] = W[i]; } } ll query(int L, int R) { vector<ll> coef(n, 0), sub(n, 0); for(int i = n - 1; i >= 0; i--){ if(sub[i] < L){ coef[i] = L - sub[i]; } else if(sub[i] > R){ coef[i] = R[i] - sub[i]; } else{ coef[i] = 0; } sub[i] += coef[i]; if(i > 0) sub[p[i]] += sub[i]; } ll tot = 0; for(int i = 0; i < n; i++){ tot += w[i] * abs(coef[i]); } return tot; } /*void _(){ } int32_t main(){ cin.tie(0); ios::sync_with_stdio(0); int tc=1;//cin >> tc; while(tc--) _(); return 0; }*/

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

tree.cpp: In function 'long long int query(int, int)':
tree.cpp:27:17: error: invalid types 'int[int]' for array subscript
   27 |      coef[i] = R[i] - sub[i];
      |                 ^