Submission #1018047

#TimeUsernameProblemLanguageResultExecution timeMemory
1018047codefoxHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #define pii pair<int, int> #define pipi pair<pii, pii> int N = 1<<20; int bin[2*N]; vector<int> bmm[2*N]; int sol = 0; int query(int curr, int l, int r, int a, int b, int mx) { if (l >= b || r <= a) return -1e9; if (a <= l && r <= b) { sol = max(sol, bin[curr]); auto u = lower_bound(bmm[curr].begin(), bmm[curr].end(), mx); if (u!= bmm[curr].begin()) { int last = *(--u); sol = max(sol, mx+last); } return bmm[curr].back(); } int m = (l+r)/2; mx = max(mx, query(curr*2, l, m, a, b, mx)); mx = max(mx, query(curr*2+1, m, r, a, b, mx)); return mx; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; for (int i = 0; i < 2*N;i ++) bin[i]=0; for (int i = 0; i < n; i++) { int a; cin >> a; bmm[i+N].push_back(a); } for (int i = n; i < N; i++) bmm[i+N].push_back(1e9); for (int i = N-1; i >0; i--) { bmm[i] = vector<int>(bmm[i*2]); for (int ele:bmm[i*2+1]) bmm[i].push_back(ele); sort(bmm[i].begin(), bmm[i].end()); bin[i] = max(bin[i*2], bin[i*2+1]); int mx = bmm[i*2].back(); auto u = lower_bound(bmm[i*2+1].begin(), bmm[i*2+1].end(), mx); if (u!=bmm[i*2+1].begin()) { bin[i] = max(bin[i], mx+*(--u)); } } while(q--) { int l, r, mood; cin >> l >> r >> mood; l--; sol=0; query(1, 0, N, l, r, -1e9); if (sol <= mood) cout << "1\n"; else cout << "0\n"; } return 0; }

Compilation message (stderr)

sortbooks.cpp:11:12: error: array bound is not an integer constant before ']' token
   11 | int bin[2*N];
      |            ^
sortbooks.cpp:12:20: error: array bound is not an integer constant before ']' token
   12 | vector<int> bmm[2*N];
      |                    ^
sortbooks.cpp: In function 'int query(int, int, int, int, int, int)':
sortbooks.cpp:20:24: error: 'bin' was not declared in this scope; did you mean 'sin'?
   20 |         sol = max(sol, bin[curr]);
      |                        ^~~
      |                        sin
sortbooks.cpp:21:30: error: 'bmm' was not declared in this scope
   21 |         auto u = lower_bound(bmm[curr].begin(), bmm[curr].end(), mx);
      |                              ^~~
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:44:35: error: 'bin' was not declared in this scope; did you mean 'sin'?
   44 |     for (int i = 0; i < 2*N;i ++) bin[i]=0;
      |                                   ^~~
      |                                   sin
sortbooks.cpp:49:9: error: 'bmm' was not declared in this scope
   49 |         bmm[i+N].push_back(a);
      |         ^~~
sortbooks.cpp:51:33: error: 'bmm' was not declared in this scope
   51 |     for (int i = n; i < N; i++) bmm[i+N].push_back(1e9);
      |                                 ^~~
sortbooks.cpp:54:9: error: 'bmm' was not declared in this scope
   54 |         bmm[i] = vector<int>(bmm[i*2]);
      |         ^~~
sortbooks.cpp:57:9: error: 'bin' was not declared in this scope; did you mean 'sin'?
   57 |         bin[i] = max(bin[i*2], bin[i*2+1]);
      |         ^~~
      |         sin