Submission #1053386

# Submission time Handle Problem Language Result Execution time Memory
1053386 2024-08-11T11:20:01 Z Ludissey Bikeparking (EGOI24_bikeparking) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
 
using namespace std;
int N,M,Q;
vector<int> X,y;
struct node {
	node* left, *right;
	int sum, lazy;
    node(){
        left=NULL;
        right=NULL;
        sum=0;
        lazy=-1;
    }
    void update(){
        sum=left->sum+right->sum;
    }
    void propagate(){
        if(lazy>-1){
            sum=lazy;
            if(left!=NULL){
                left->lazy=lazy;
                right->lazy=lazy;
            }
            lazy=-1;
        }
    }
};
 
void build(node* x, int l, int r){
    if(l==r) x->sum=X[l];
    else{
        x->left=new node();
        x->right=new node();
        int mid=(l+r)/2;
        build(x->left, l, mid);
        build(x->right, mid+1, r);
        x->update();
    }
}
void update(node* x, int l, int r, int qL, int qR, int v){
    x->propagate();
    if(r<qR||l>qL) return;
    if(r<=qR&&l>=qL){
        x->sum=v;
        x->lazy=v;
        return;
    }
    int mid=(l+r)/2;
    update(x->left, l, mid, qL, qR,v);
    update(x->right, mid+1, r, qL, qR,v);
    x->update();
}
 
int query(node* x, int l, int r, int qL, int qR){
    if(r<qL||l>qR) return 0;
    x->propagate();
    if(r<=qR&&l>=qL){
        return x->sum;
    }
    int mid=(l+r)/2;
    return query(x->left, l, mid, qL, qR)+query(x->right, mid+1, r, qL, qR);
}
 
signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N;
    X.resize(N),y.resize(N);
    for (int i = 0; i < N; i++) cin >> X[i];
    for (int i = 0; i < N; i++) cin >> y[i];
    node* root = new node();
    build(root,0,N-1);
    int sm=0;
    vector<int> kp(N);
    for (int i = 0; i < N; i++)
    {
        while(l>0){
            if(X[l])
        }
        if(ans+1<i) {
            int q=query(root,0,N-1,ans+1,i-1);
            y[i]-=q;
            sm+=q;
            update(root,0,N-1,ans+1,i-1,0);
        }
        if(b){
            int q=query(root,0,N-1,ans,ans);
            int df=min(q,y[i]);
            sm+=df;
            y[i]-=df;
            update(root,0,N-1,ans,ans,q-df);
        }else{
            if(ans<i){
                int q=query(root,0,N-1,ans,i-1);
                y[i]-=q;
                sm+=q;
                update(root,0,N-1,ans,i-1,0);
            }
        }
        kp[i]+=y[i];
    }   
    for (int i = 0; i < N; i++){
        int df=min(query(root,0,N-1,i,i),kp[i]);
        kp[i]-=df;
        sm-=kp[i];
    }
    cout << sm << "\n";
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:80:15: error: 'l' was not declared in this scope
   80 |         while(l>0){
      |               ^
Main.cpp:82:9: error: expected primary-expression before '}' token
   82 |         }
      |         ^
Main.cpp:83:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   83 |         if(ans+1<i) {
      |            ^~~
      |            abs
Main.cpp:89:12: error: 'b' was not declared in this scope
   89 |         if(b){
      |            ^
Main.cpp:90:36: error: 'ans' was not declared in this scope; did you mean 'abs'?
   90 |             int q=query(root,0,N-1,ans,ans);
      |                                    ^~~
      |                                    abs
Main.cpp:96:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   96 |             if(ans<i){
      |                ^~~
      |                abs