제출 #777114

#제출 시각아이디문제언어결과실행 시간메모리
777114ind1vAddk (eJOI21_addk)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 100005; const int K = 15; struct fenwick_tree { int64_t fenw[N]; fenwick_tree() { memset(fenw, 0, sizeof(fenw)); } void upd(int idx, long long val) { for (; idx < N; idx |= (idx + 1)) { fenw[idx] += val; } } int64_t get(int idx) { int64_t res = 0; for (; idx >= 0; idx &= (idx + 1), --idx) { res += fenw[idx]; } return res; } int64_t get(int l, int r) { return get(r) - get(l - 1); } }; int n, k; int a[N]; int64_t p[N]; int idx[K]; int q; fenwick_tree ft1, ft2; void upd(int idx, int64_t val) { ft1.upd(idx, val); ft2.upd(idx, 1LL * idx * val); } int64_t get(int idx) { return 1LL * (idx + 1) * ft1.get(idx) - ft2.get(idx); } int64_t get(int l, int r) { return get(r) - get(l - 1); } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; p[i] = a[i] + p[i - 1]; } for (int i = 1; i <= n; i++) { upd(i, p[i] - p[i - 1]); } cin >> q; while (q--) { int t; cin >> t; if (t == 1) { for (int i = 1; i <= k; i++) { cin >> idx[i]; } idx[k + 1] = idx[1]; for (int i = 1; i <= k; i++) { upd(idx[i], a[idx[i + 1]] - a[idx[i]]); } int tmp = a[idx[1]]; for (int i = 1; i <= k - 1; i++) { a[idx[i]] = a[idx[i + 1]]; } a[idx[k]] = tmp; } else if (t == 2) { int l, r, m; cin >> l >> r >> m; cout << ft.get(min(l + m - 1, r), r) - ft.get(min(l + m - 1, r) - m, r - m) << '\n'; } } return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:85:15: error: 'ft' was not declared in this scope; did you mean 't'?
   85 |       cout << ft.get(min(l + m - 1, r), r) - ft.get(min(l + m - 1, r) - m, r - m) << '\n';
      |               ^~
      |               t