Submission #476118

# Submission time Handle Problem Language Result Execution time Memory
476118 2021-09-24T19:41:42 Z Haidara Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
/** * * * * * * * * * * * * * **\
 *                             *
 *   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=1e9+7;
const int mod=1e9+7;
const int maxn=200001;
int n;
struct node
{
    int min=inf,max=0,lazy=0,val=0;
    node():min(inf),max(0),val(0),lazy(0){}
}st[maxn*4];
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;
}
v(int)a;
void build(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);
    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 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);
}
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);
}
vector<__int32> distribute_candies(vector<__int32> C, vector<__int32> L, vector<__int32> R, vector<__int32> V)
{
    n=C.size();
    a=C;
    build();
    FOR(i,(int)L.size())
        update(L[i]+1,R[i]+1,V[i]);
    v(int)ans(n);
    FOR(i,n)
        ans[i]=min(C[i],query(i+1));
    return ans;
}

Compilation message

candies.cpp: In constructor 'node::node()':
candies.cpp:38:30: warning: 'node::val' will be initialized after [-Wreorder]
   38 |     int min=inf,max=0,lazy=0,val=0;
      |                              ^~~
candies.cpp:38:23: warning:   'long long int node::lazy' [-Wreorder]
   38 |     int min=inf,max=0,lazy=0,val=0;
      |                       ^~~~
candies.cpp:39:5: warning:   when initialized here [-Wreorder]
   39 |     node():min(inf),max(0),val(0),lazy(0){}
      |     ^~~~
candies.cpp: At global scope:
candies.cpp:93:8: error: '__int32' was not declared in this scope; did you mean '__rintf32'?
   93 | vector<__int32> distribute_candies(vector<__int32> C, vector<__int32> L, vector<__int32> R, vector<__int32> V)
      |        ^~~~~~~
      |        __rintf32
candies.cpp:93:15: error: template argument 1 is invalid
   93 | vector<__int32> distribute_candies(vector<__int32> C, vector<__int32> L, vector<__int32> R, vector<__int32> V)
      |               ^
candies.cpp:93:15: error: template argument 2 is invalid
candies.cpp:93:43: error: '__int32' was not declared in this scope; did you mean '__rintf32'?
   93 | vector<__int32> distribute_candies(vector<__int32> C, vector<__int32> L, vector<__int32> R, vector<__int32> V)
      |                                           ^~~~~~~
      |                                           __rintf32
candies.cpp:93:50: error: template argument 1 is invalid
   93 | vector<__int32> distribute_candies(vector<__int32> C, vector<__int32> L, vector<__int32> R, vector<__int32> V)
      |                                                  ^
candies.cpp:93:50: error: template argument 2 is invalid
candies.cpp:93:62: error: '__int32' was not declared in this scope; did you mean '__rintf32'?
   93 | vector<__int32> distribute_candies(vector<__int32> C, vector<__int32> L, vector<__int32> R, vector<__int32> V)
      |                                                              ^~~~~~~
      |                                                              __rintf32
candies.cpp:93:69: error: template argument 1 is invalid
   93 | vector<__int32> distribute_candies(vector<__int32> C, vector<__int32> L, vector<__int32> R, vector<__int32> V)
      |                                                                     ^
candies.cpp:93:69: error: template argument 2 is invalid
candies.cpp:93:81: error: '__int32' was not declared in this scope; did you mean '__rintf32'?
   93 | vector<__int32> distribute_candies(vector<__int32> C, vector<__int32> L, vector<__int32> R, vector<__int32> V)
      |                                                                                 ^~~~~~~
      |                                                                                 __rintf32
candies.cpp:93:88: error: template argument 1 is invalid
   93 | vector<__int32> distribute_candies(vector<__int32> C, vector<__int32> L, vector<__int32> R, vector<__int32> V)
      |                                                                                        ^
candies.cpp:93:88: error: template argument 2 is invalid
candies.cpp:93:100: error: '__int32' was not declared in this scope; did you mean '__rintf32'?
   93 | vector<__int32> distribute_candies(vector<__int32> C, vector<__int32> L, vector<__int32> R, vector<__int32> V)
      |                                                                                                    ^~~~~~~
      |                                                                                                    __rintf32
candies.cpp:93:107: error: template argument 1 is invalid
   93 | vector<__int32> distribute_candies(vector<__int32> C, vector<__int32> L, vector<__int32> R, vector<__int32> V)
      |                                                                                                           ^
candies.cpp:93:107: error: template argument 2 is invalid
candies.cpp: In function 'int distribute_candies(int, int, int, int)':
candies.cpp:95:9: error: request for member 'size' in 'C', which is of non-class type 'int'
   95 |     n=C.size();
      |         ^~~~
candies.cpp:96:7: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'int')
   96 |     a=C;
      |       ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:8:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'int' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:8:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'int' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
candies.cpp:98:18: error: request for member 'size' in 'L', which is of non-class type 'int'
   98 |     FOR(i,(int)L.size())
      |                  ^~~~
candies.cpp:12:37: note: in definition of macro 'rep'
   12 | #define rep(i,x,n) for(int i=(x);i<(n);i++)
      |                                     ^
candies.cpp:98:5: note: in expansion of macro 'FOR'
   98 |     FOR(i,(int)L.size())
      |     ^~~
candies.cpp:99:17: error: invalid types 'int[long long int]' for array subscript
   99 |         update(L[i]+1,R[i]+1,V[i]);
      |                 ^
candies.cpp:99:24: error: invalid types 'int[long long int]' for array subscript
   99 |         update(L[i]+1,R[i]+1,V[i]);
      |                        ^
candies.cpp:99:31: error: invalid types 'int[long long int]' for array subscript
   99 |         update(L[i]+1,R[i]+1,V[i]);
      |                               ^
candies.cpp:102:21: error: invalid types 'int[long long int]' for array subscript
  102 |         ans[i]=min(C[i],query(i+1));
      |                     ^
candies.cpp:103:12: error: cannot convert 'std::vector<long long int>' to 'int' in return
  103 |     return ans;
      |            ^~~