Submission #70860

#TimeUsernameProblemLanguageResultExecution timeMemory
70860zadrgaSterilizing Spray (JOI15_sterilizing)C++14
Compilation error
0 ms0 KiB
// 15.22 #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define fi first #define se second #define INF (1LL << 55) #define MOD (1000 * 1000 * 1000 + 7) #define maxn 100111 #define logn 35 typedef long long ll; typedef long double ld; typedef pair<ll, ll> pii; ll K; ll arr[maxn]; struct segtree{ ll seg[4 * maxn][logn]; ll lazy[4 * maxn]; void push(ll x, ll l, ll d){ if(lazy[x] == 0 || K == 1){ return; lazy[x] = min(lazy[x], logn); ll k = lazy[x]; for(ll i = 0; i + k < logn; i++) seg[x][i] = seg[x][i + k]; for(ll i = logn - k; i < logn; i++) seg[x][i] = 0; if(l != d){ lazy[2 * x] += lazy[x]; lazy[2 * x + 1] += lazy[x]; } lazy[x] = 0; } void combine(ll x, ll l, ll d){ for(ll i = 0; i < logn; i++) seg[x][i] = seg[l][i] + seg[d][i]; } void setValue(ll x, ll val){ seg[x][0] = val; for(ll i = 1; i < logn; i++) seg[x][i] = seg[x][i - 1] / K; } void build(ll x, ll l, ll d){ if(l > d) return; if(l == d){ setValue(x, arr[l]); lazy[x] = 0; return; } ll mid = (l + d) / 2; build(2 * x, l, mid); build(2 * x + 1, mid + 1, d); combine(x, 2 * x, 2 * x + 1); lazy[x] = 0; } void update(ll x, ll l, ll d, ll i, ll val){ push(x, l, d); if(l > d || l > i || d < i) return; if(l == d && l == i){ setValue(x, val); return; } ll mid = (l + d) / 2; update(2 * x, l, mid, i, val); update(2 * x + 1, mid + 1, d, i, val); combine(x, 2 * x, 2 * x + 1); } void reduce(ll x, ll l, ll d, ll i, ll j){ push(x, l, d); if(l > d || l > j || d < i) return; if(i <= l && d <= j){ lazy[x] = 1; push(x, l, d); return; } ll mid = (l + d) / 2; reduce(2 * x, l, mid, i, j); reduce(2 * x + 1, mid + 1, d, i, j); combine(x, 2 * x, 2 * x + 1); } ll query(ll x, ll l, ll d, ll i, ll j){ push(x, l, d); if(l > d || l > j || d < i) return 0; if(i <= l && d <= j) return seg[x][0]; ll mid = (l + d) / 2; ll ret = query(2 * x, l, mid, i, j); ret += query(2 * x + 1, mid + 1, d, i, j); return ret; } }seg; int main(){ ll n, q; scanf("%lld%lld%lld", &n, &q, &K); for(ll i = 1; i <= n; i++) scanf("%lld", arr + i); seg.build(1, 1, n); while(q--){ ll t, x, y; scanf("%lld%lld%lld", &t, &x, &y); if(t == 1) seg.update(1, 1, n, x, y); if(t == 2) seg.reduce(1, 1, n, x, y); if(t == 3) printf("%lld\n", seg.query(1, 1, n, x, y)); } return 0; }

Compilation message (stderr)

sterilizing.cpp:121:2: error: 'seg' does not name a type; did you mean 'se'?
 }seg;
  ^~~
  se
sterilizing.cpp:146:1: error: expected '}' at end of input
 }
 ^
sterilizing.cpp: In member function 'void segtree::push(ll, ll, ll)':
sterilizing.cpp:31:30: error: no matching function for call to 'min(ll&, int)'
   lazy[x] = min(lazy[x], logn);
                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from sterilizing.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
sterilizing.cpp:31:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   lazy[x] = min(lazy[x], logn);
                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from sterilizing.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
sterilizing.cpp:31:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   lazy[x] = min(lazy[x], logn);
                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from sterilizing.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
sterilizing.cpp:31:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   lazy[x] = min(lazy[x], logn);
                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from sterilizing.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
sterilizing.cpp:31:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   lazy[x] = min(lazy[x], logn);
                              ^
sterilizing.cpp:47:32: error: a function-definition is not allowed here before '{' token
  void combine(ll x, ll l, ll d){
                                ^
sterilizing.cpp:52:29: error: a function-definition is not allowed here before '{' token
  void setValue(ll x, ll val){
                             ^
sterilizing.cpp:58:30: error: a function-definition is not allowed here before '{' token
  void build(ll x, ll l, ll d){
                              ^
sterilizing.cpp:75:45: error: a function-definition is not allowed here before '{' token
  void update(ll x, ll l, ll d, ll i, ll val){
                                             ^
sterilizing.cpp:91:43: error: a function-definition is not allowed here before '{' token
  void reduce(ll x, ll l, ll d, ll i, ll j){
                                           ^
sterilizing.cpp:108:40: error: a function-definition is not allowed here before '{' token
  ll query(ll x, ll l, ll d, ll i, ll j){
                                        ^
sterilizing.cpp: In member function 'int segtree::main()':
sterilizing.cpp:129:6: error: request for member 'build' in '((segtree*)this)->segtree::seg', which is of non-class type 'll [400444][35] {aka long long int [400444][35]}'
  seg.build(1, 1, n);
      ^~~~~
sterilizing.cpp:136:8: error: request for member 'update' in '((segtree*)this)->segtree::seg', which is of non-class type 'll [400444][35] {aka long long int [400444][35]}'
    seg.update(1, 1, n, x, y);
        ^~~~~~
sterilizing.cpp:139:8: error: request for member 'reduce' in '((segtree*)this)->segtree::seg', which is of non-class type 'll [400444][35] {aka long long int [400444][35]}'
    seg.reduce(1, 1, n, x, y);
        ^~~~~~
sterilizing.cpp:142:25: error: request for member 'query' in '((segtree*)this)->segtree::seg', which is of non-class type 'll [400444][35] {aka long long int [400444][35]}'
    printf("%lld\n", seg.query(1, 1, n, x, y));
                         ^~~~~
sterilizing.cpp: At global scope:
sterilizing.cpp:146:1: error: expected unqualified-id at end of input
 }
 ^