Submission #476099

#TimeUsernameProblemLanguageResultExecution timeMemory
476099HaidaraDistributing Candies (IOI21_candies)C++17
Compilation error
0 ms0 KiB
/** * * * * * * * * * * * * * **\ * * * Author: Haidara Nassour * * Coded in: YYYY\M\D HH:MM:SS * * Lang: C++ * * * \** * * * * * * * * * * * * * **/ #include<bits/stdc++.h> #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define int long long #define itn int #define rep(i,x,n) for(int i=(x);i<(n);i++) #define FOR(i,n) rep(i,0,n) #define per(i,x,n) for(int i=(x);i>(n);i--) #define ROF(i,x) for(int i=x;i>=0;i--) #define v(i) vector< i > #define p(i,j) pair< i , j > #define pii pair<int,int> #define m(i,j) map< i , j > #define um(i,j) unordered_map< i , j > #define max_heap(i) priority_queue< i > #define min_heap(i) priority_queue< i , vector< i > ,greater< i > > #define ff first #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define ss second #define pp push_back #define mini(x,y) x=min(x,y) #define maxi(x,y) x=max(x,y) #define debug(x) cout<<#x<<" "; using namespace std; const int inf=1LL<<62LL; const int mod=1e9+7; const int maxn=200200; struct node { int min,max,lazy,val; node():min(inf),max(0),val(0),lazy(0){} }st[maxn*4]; void pup(int inx) { st[inx].min=min(st[inx*2].min,st[inx*2+1].min); st[inx].max=max(st[inx*2].max,st[inx*2+1].max); } void pull(int inx,int l,int r) { st[inx].val+=st[inx].lazy; st[inx].val=min(st[inx].val,st[inx].max); st[inx].val=max(st[inx].val,st[inx].min); if(l!=r) { st[inx*2].lazy+=st[inx].lazy; st[inx*2+1].lazy+=st[inx].lazy; } st[inx].lazy=0; } void build(v(int)a,int l=1,int r=n,int inx=1) { if(l==r) { st[inx].min=a[l-1]; st[inx].max=a[l-1]; return ; } int mid=l+(r-l)/2; build(l,mid,inx*2); build(mid+1,r,inx*2+1); pup(inx); } void update(int ul,int ur,int val,int l=1,int r=n,int inx=1) { pull(inx,l,r); if(ul<=l&&r<=ur) { st[inx].lazy+=val; pull(inx,l,r); return ; } if(l>ur||ul>r) return ; int mid=l+(r-l)/2; update(ul,ur,val,l,mid,inx*2); update(ul,ur,val,mid+1,r,inx*2+1); pup(inx); } int query(int pos,int l=1,int r=n,int inx=1) { pull(inx,l,r); if(l==r) return st[inx].val; int mid=l+(r-l)/2; if(pos<=mid) return query(pos,l,mid,inx*2); return query(pos,mid+1,r,inx*2+1); } v(int) distribute_candies(v(int)c,v(int)l,v(int)r,v(int)val) { build(c); int n=c.size(); FOR(i,l.size()) update(l[i]+1,r[i]+1,val[i]); v(int)ans(n); FOR(i,n) ans[i]=query(i+1); return ans; }

Compilation message (stderr)

candies.cpp: In constructor 'node::node()':
candies.cpp:37:22: warning: 'node::val' will be initialized after [-Wreorder]
   37 |     int min,max,lazy,val;
      |                      ^~~
candies.cpp:37:17: warning:   'long long int node::lazy' [-Wreorder]
   37 |     int min,max,lazy,val;
      |                 ^~~~
candies.cpp:38:5: warning:   when initialized here [-Wreorder]
   38 |     node():min(inf),max(0),val(0),lazy(0){}
      |     ^~~~
candies.cpp: At global scope:
candies.cpp:57:34: error: 'n' was not declared in this scope
   57 | void build(v(int)a,int l=1,int r=n,int inx=1)
      |                                  ^
candies.cpp: In function 'void build(std::vector<long long int>, long long int, long long int, long long int)':
candies.cpp:66:11: error: could not convert 'l' from 'long long int' to 'std::vector<long long int>'
   66 |     build(l,mid,inx*2);
      |           ^
      |           |
      |           long long int
candies.cpp:67:14: error: could not convert '(mid + 1)' from 'long long int' to 'std::vector<long long int>'
   67 |     build(mid+1,r,inx*2+1);
      |           ~~~^~
      |              |
      |              long long int
candies.cpp: At global scope:
candies.cpp:70:49: error: 'n' was not declared in this scope
   70 | void update(int ul,int ur,int val,int l=1,int r=n,int inx=1)
      |                                                 ^
candies.cpp:86:33: error: 'n' was not declared in this scope
   86 | int query(int pos,int l=1,int r=n,int inx=1)
      |                                 ^
candies.cpp: In function 'std::vector<long long int> distribute_candies(std::vector<long long int>, std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
candies.cpp:12:35: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 | #define rep(i,x,n) for(int i=(x);i<(n);i++)
      |                                   ^
candies.cpp:13:18: note: in expansion of macro 'rep'
   13 | #define FOR(i,n) rep(i,0,n)
      |                  ^~~
candies.cpp:100:5: note: in expansion of macro 'FOR'
  100 |     FOR(i,l.size())
      |     ^~~