Submission #1068524

#TimeUsernameProblemLanguageResultExecution timeMemory
1068524GrindMachineGame (IOI13_game)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; typedef long long int ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) #define pb push_back #define endl '\n' #define sz(a) (int)a.size() #define setbits(x) __builtin_popcountll(x) #define ff first #define ss second #define conts continue #define ceil2(x,y) ((x+y-1)/(y)) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define yes cout << "Yes" << endl #define no cout << "No" << endl #define rep(i,n) for(int i = 0; i < n; ++i) #define rep1(i,n) for(int i = 1; i <= n; ++i) #define rev(i,s,e) for(int i = s; i >= e; --i) #define trav(i,a) for(auto &i : a) template<typename T> void amin(T &a, T b) { a = min(a,b); } template<typename T> void amax(T &a, T b) { a = max(a,b); } #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif /* already knew the solution idea (dynamic segtree with a treap/dynamic segtree in each node) */ const int MOD = 1e9 + 7; const int N = 1e5 + 5; const int inf1 = int(1e9) + 5; const ll inf2 = ll(1e18) + 5; #include "game.h" struct dynamic_segtree{ struct node{ node *l = nullptr, *r = nullptr; ll g = 0; node(){ } node(ll x){ g = x; } }; node* root; int n; dynamic_segtree(){ } dynamic_segtree(int n_){ n = n_; root = new node(); } void pupd(node* &u, int lx, int rx, int i, ll v){ if(!u) u = new node(); if(rx-lx == 1){ u->g = v; return; } int mid = (lx+rx) >> 1; if(i < mid){ pupd(u->l,lx,mid,i,v); } else{ pupd(u->r,mid,rx,i,v); } u->g = 0; if(u->l) u->g = gcd(u->g,u->l->g); if(u->r) u->g = gcd(u->g,u->r->g); } void pupd(int i, ll v){ pupd(root,0,n,i,v); } ll query(node* u, int lx, int rx, int l, int r){ if(!u) return 0; if(lx >= r or rx <= l) return 0; if(lx >= l and rx <= r) return u->g; int mid = (lx+rx) >> 1; return gcd(query(u->l,lx,mid,l,r),query(u->r,mid,rx,l,r)); } ll query(ll l, ll r){ return query(root,0,n,l,r+1); } }; struct seg2d{ int n,m; struct node{ node *l = nullptr, *r = nullptr; dynamic_segtree st; node(int m_){ st = dynamic_segtree(m_); } }; node* root; seg2d(){ } seg2d(int n_, int m_){ n = n_, m = m_; root = new node(m); } void pupd(node* &u, int lx, int rx, int i, int j, ll v){ if(!u) u = new node(); if(rx-lx == 1){ u->st.pupd(j,v); return; } int mid = (lx+rx) >> 1; if(i < mid){ pupd(u->l,lx,mid,i,j,v); } else{ pupd(u->r,mid,rx,i,j,v); } ll g = 0; if(u->l) g = u->l->st.query(j,j); if(u->r) g = gcd(g,u->r->st.query(j,j)); u->st.pupd(j,g); } void pupd(int i, int j, ll v){ pupd(root,0,n,i,j,v); } ll query(node* u, int lx, int rx, int l, int r, int x, int y){ if(!u) return 0; if(lx >= r or rx <= l) return 0; if(lx >= l and rx <= r) return u->st.query(x,y); int mid = (lx+rx) >> 1; return gcd(query(u->l,lx,mid,l,r,x,y),query(u->r,mid,rx,l,r,x,y)); } ll query(int l, int r, int x, int y){ return query(root,0,n,l,r+1,x,y); } }; seg2d st; void init(int n, int m) { st = seg2d(n,m); } void update(int i, int j, long long v) { st.pupd(i,j,v); } long long calculate(int l1, int l2, int r1, int r2) { return st.query(l1,r1,l2,r2); }

Compilation message (stderr)

game.cpp: In member function 'void seg2d::pupd(seg2d::node*&, int, int, int, int, ll)':
game.cpp:148:29: error: no matching function for call to 'seg2d::node::node()'
  148 |         if(!u) u = new node();
      |                             ^
game.cpp:131:9: note: candidate: 'seg2d::node::node(int)'
  131 |         node(int m_){
      |         ^~~~
game.cpp:131:9: note:   candidate expects 1 argument, 0 provided
game.cpp:128:12: note: candidate: 'constexpr seg2d::node::node(const seg2d::node&)'
  128 |     struct node{
      |            ^~~~
game.cpp:128:12: note:   candidate expects 1 argument, 0 provided
game.cpp:128:12: note: candidate: 'constexpr seg2d::node::node(seg2d::node&&)'
game.cpp:128:12: note:   candidate expects 1 argument, 0 provided