(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #944764

#TimeUsernameProblemLanguageResultExecution timeMemory
944764WongYiKaiMeetings (IOI18_meetings)C++14
Compilation error
0 ms0 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; struct node { int s, e; ll mn, mx, sum; bool lset; ll add_val, set_val; node *l, *r; node (int _s, int _e, int A[] = NULL): s(_s), e(_e), mn(0), mx(0), sum(0), lset(0), add_val(0), set_val(0), l(NULL), r(NULL) { if (A == NULL) return; if (s == e) mn = mx = sum = A[s]; else { l = new node(s, (s+e)>>1, A), r = new node((s+e+2)>>1, e, A); combine(); } } void create_children() { if (s == e) return; if (l != NULL) return; int m = (s+e)>>1; l = new node(s, m); r = new node(m+1, e); } void self_set(ll v) { lset = 1; mn = mx = set_val = v; sum = v * (e-s+1); add_val = 0; } void self_add(ll v) { if (lset) { self_set(v + set_val); return; } mn += v, mx += v, add_val += v; sum += v*(e-s+1); } void lazy_propagate() { if (s == e) return; if (lset) { l->self_set(set_val), r->self_set(set_val); lset = set_val = 0; } if (add_val != 0) { l->self_add(add_val), r->self_add(add_val); add_val = 0; } } void combine() { if (l == NULL) return; sum = l->sum + r->sum; mn = min(l->mn, r->mn); mx = max(l->mx, r->mx); } void add(int x, int y, ll v) { if (s == x && e == y) { self_add(v); return; } int m = (s+e)>>1; create_children(); lazy_propagate(); if (x <= m) l->add(x, min(y, m), v); if (y > m) r->add(max(x, m+1), y, v); combine(); } void set(int x, int y, ll v) { if (s == x && e == y) { self_set(v); return; } int m = (s+e)>>1; create_children(); lazy_propagate(); if (x <= m) l->set(x, min(y, m), v); if (y > m) r->set(max(x, m+1), y, v); combine(); } ll range_sum(int x, int y) { if (s == x && e == y) return sum; if (l == NULL || lset) return (sum / (e-s+1)) * (y-x+1); int m = (s+e)>>1; lazy_propagate(); if (y <= m) return l->range_sum(x, y); if (x > m) return r->range_sum(x, y); return l->range_sum(x, m) + r->range_sum(m+1, y); } ll range_min(int x, int y) { if (s == x && e == y) return mn; if (l == NULL || lset) return mn; int m = (s+e)>>1; lazy_propagate(); if (y <= m) return l->range_min(x, y); if (x > m) return r->range_min(x, y); return min(l->range_min(x, m), r->range_min(m+1, y)); } ll range_max(int x, int y) { if (s == x && e == y) return mx; if (l == NULL || lset) return mx; int m = (s+e)>>1; lazy_propagate(); if (y <= m) return l->range_max(x, y); if (x > m) return r->range_max(x, y); return max(l->range_max(x, m), r->range_max(m+1, y)); } ~node() { if (l != NULL) delete l; if (r != NULL) delete r; } } *root; vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) { ll n = H.size(); ll q = L.size(); vector<ll> c; root = new node(0,n+5); //root2 = new node(0,n+5); for (int i=0;i<n;i++){ root->set(i,i,H[i]); } for (int i=0;i<q;i++){ ll l = L[i]; ll r = R[i]; //root->set(l,r,0); //root2->set(l,r,0); ll dpl[n+5],dpr[n+5]; dpr[l] = 0; ll mx=-1; deque<ll> is; for (int j=l;j<=r;j++){ if (H[j]>mx){ is.push_back(j); mx = H[j]; } dpr[l] += mx; } for (int j=l+1;j<=r;j++){ if (is.front()<j){ is.pop_front(); stack<ll> temp; temp.push(H[j]); ll sec = is.front(); if (sec==j) continue; if (root->range_max(j,sec-1)==j){ is.push_front(temp.top()); continue; } ll l2=j,r2=sec-1; return c; }

Compilation message (stderr)

meetings.cpp: In member function 'void node::lazy_propagate()':
meetings.cpp:43:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   43 |             lset = set_val = 0;
      |                    ~~~~~~~~^~~
meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:141:9: warning: unused variable 'l2' [-Wunused-variable]
  141 |      ll l2=j,r2=sec-1;
      |         ^~
meetings.cpp:141:14: warning: unused variable 'r2' [-Wunused-variable]
  141 |      ll l2=j,r2=sec-1;
      |              ^~
meetings.cpp:144:1: error: expected '}' at end of input
  144 | }
      | ^
meetings.cpp:130:28: note: to match this '{'
  130 |    for (int j=l+1;j<=r;j++){
      |                            ^
meetings.cpp:144:1: error: expected '}' at end of input
  144 | }
      | ^
meetings.cpp:114:24: note: to match this '{'
  114 |   for (int i=0;i<q;i++){
      |                        ^
meetings.cpp:119:7: warning: unused variable 'dpl' [-Wunused-variable]
  119 |    ll dpl[n+5],dpr[n+5];
      |       ^~~
meetings.cpp:144:1: error: expected '}' at end of input
  144 | }
      | ^
meetings.cpp:105:71: note: to match this '{'
  105 | vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
      |                                                                       ^
meetings.cpp:144:1: warning: control reaches end of non-void function [-Wreturn-type]
  144 | }
      | ^