Submission #1090853

#TimeUsernameProblemLanguageResultExecution timeMemory
1090853LeonidCukGame (IOI13_game)C++17
Compilation error
0 ms0 KiB
#include "game.h" #include <bits/stdc++.h> typedef long long ll; static int R, C; struct xnod{ xnod(int tl, int tr):tl(tl),tr(tr),l(NULL),r(NULL),value(0LL) {} int tl,tr; xnod *l,*r; ll value; }; struct ynod{ ynod():l(NULL),r(NULL),xst(1,C){} ynod *l,*r; xnod xst; } *root; void init(int r, int c) { R=r,C=c; root=new ynod(); } void update2(xnod *nod,int q,ll k) { int tl=node->tl,tr=node->tr,m=(tl+tr)/2; if (tl==tr) { node->value=k; return; } xnod**koce=&(q<=m?nod->l:nod->r); if (*koce==NULL) { *koce=new xnod(q, q); (*koce)->value = k; } else if ((*koce)->tl <= q && q <= (*koce)->tr) { update2(*koce, q, k); } else { do { if (q <= m) tl = m; else tr = m + 1; m = (tl + tr) >> 1; } while ((q <= m) == ((*koce)->tr <= m)); xnod *temp= new xnod(tl, tr); if ((*koce)->tr <= m) temp->l = *koce; else temp->r = *koce; *koce = temp; update2(*koce, q, k); } nod->value =gcd2(nod->l ? nod->l->value : 0, nod->r?nod->r->value : 0); } ll query2(xnod *node,int tl, int tr) { if (node == NULL || node->tl > tr || node->tr < tl) return 0; if (tl <= node->tl && node->tr <= tr) { return node->value; } return gcd2(query2(node->l, tl, tr), query2(node->r, tl, tr)); } void update1(ynod *node, int tl, int tr, int vx, int vy, ll k) { int m = (tl + tr)/2; if (tr == tl) { update2(&node->xst, vy, k); return; } if (vx <= m) { if (node->l == NULL) node->l = new ynod(); update1(node->l, tl, m, vx, vy, k); } else { if (node->r == NULL) node->r = new ynod(); update1(node->r, m + 1, tr, vx, vy, k); } ll v = gcd2(node->l ? query2(&node->l->xst, vy, vy) : 0, node->r ? query2(&node->r->xst, vy, vy) : 0); update2(&node->xst, vy, v); } void update(int vx, int vy, ll k) { ++vx, ++vy; update1(root, 1, R, vx, vy, k); } ll query1(ynod *node, int tl, int tr, int vxl, int vyl, int vxr, int vxl) { if (node == NULL || tl > vxr || tr < vxl) return 0; if (vxl <= tl && tr<=vxr) return query2(&node->xst, vyl, vyr); int m = (tl+tr)/2; return gcd(query1(node->l, tr, m, vxl, vyl, vxr, vyr),query1(node->right, m + 1, tr, vxl, vyl,vxr,vyr)); } ll calculate(int vxl, int vyl, int vxr, int vyr) { ++vxl, ++vyl, ++vxr, ++vyr; return query1(root, 1, R, vxl, vyl, vxr, vyr); }

Compilation message (stderr)

game.cpp: In function 'void update2(xnod*, int, ll)':
game.cpp:22:9: error: 'node' was not declared in this scope; did you mean 'nod'?
   22 |  int tl=node->tl,tr=node->tr,m=(tl+tr)/2;
      |         ^~~~
      |         nod
game.cpp:23:10: error: 'tr' was not declared in this scope; did you mean 'tl'?
   23 |  if (tl==tr) {
      |          ^~
      |          tl
game.cpp:27:18: error: 'm' was not declared in this scope
   27 |  xnod**koce=&(q<=m?nod->l:nod->r);
      |                  ^
game.cpp:36:9: error: 'tr' was not declared in this scope; did you mean 'tl'?
   36 |    else tr = m + 1;
      |         ^~
      |         tl
game.cpp:37:14: error: 'tr' was not declared in this scope; did you mean 'tl'?
   37 |    m = (tl + tr) >> 1;
      |              ^~
      |              tl
game.cpp:39:28: error: 'tr' was not declared in this scope; did you mean 'tl'?
   39 |   xnod *temp= new xnod(tl, tr);
      |                            ^~
      |                            tl
game.cpp:45:14: error: 'gcd2' was not declared in this scope
   45 |  nod->value =gcd2(nod->l ? nod->l->value : 0, nod->r?nod->r->value : 0);
      |              ^~~~
game.cpp: In function 'll query2(xnod*, int, int)':
game.cpp:50:9: error: 'gcd2' was not declared in this scope
   50 |  return gcd2(query2(node->l, tl, tr), query2(node->r, tl, tr));
      |         ^~~~
game.cpp: In function 'void update1(ynod*, int, int, int, int, ll)':
game.cpp:66:9: error: 'gcd2' was not declared in this scope
   66 |  ll v = gcd2(node->l ? query2(&node->l->xst, vy, vy) : 0,
      |         ^~~~
game.cpp: At global scope:
game.cpp:76:70: error: redefinition of 'int vxl'
   76 | ll query1(ynod *node, int tl, int tr, int vxl, int vyl, int vxr, int vxl) {
      |                                                                  ~~~~^~~
game.cpp:76:43: note: 'int vxl' previously declared here
   76 | ll query1(ynod *node, int tl, int tr, int vxl, int vyl, int vxr, int vxl) {
      |                                       ~~~~^~~
game.cpp: In function 'll query1(ynod*, int, int, int, int, int)':
game.cpp:78:59: error: 'vyr' was not declared in this scope; did you mean 'vyl'?
   78 |  if (vxl <= tl && tr<=vxr) return query2(&node->xst, vyl, vyr);
      |                                                           ^~~
      |                                                           vyl
game.cpp:80:51: error: 'vyr' was not declared in this scope; did you mean 'vyl'?
   80 |  return gcd(query1(node->l, tr, m, vxl, vyl, vxr, vyr),query1(node->right, m + 1, tr, vxl, vyl,vxr,vyr));
      |                                                   ^~~
      |                                                   vyl
game.cpp:80:69: error: 'struct ynod' has no member named 'right'
   80 |  return gcd(query1(node->l, tr, m, vxl, vyl, vxr, vyr),query1(node->right, m + 1, tr, vxl, vyl,vxr,vyr));
      |                                                                     ^~~~~
game.cpp:80:9: error: 'gcd' was not declared in this scope; did you mean 'std::gcd'?
   80 |  return gcd(query1(node->l, tr, m, vxl, vyl, vxr, vyr),query1(node->right, m + 1, tr, vxl, vyl,vxr,vyr));
      |         ^~~
      |         std::gcd
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from game.cpp:2:
/usr/include/c++/10/numeric:131:5: note: 'std::gcd' declared here
  131 |     gcd(_Mn __m, _Nn __n)
      |     ^~~
game.cpp: In function 'll calculate(int, int, int, int)':
game.cpp:85:46: error: too many arguments to function 'll query1(ynod*, int, int, int, int, int)'
   85 |  return query1(root, 1, R, vxl, vyl, vxr, vyr);
      |                                              ^
game.cpp:76:4: note: declared here
   76 | ll query1(ynod *node, int tl, int tr, int vxl, int vyl, int vxr, int vxl) {
      |    ^~~~~~