Submission #1090520

# Submission time Handle Problem Language Result Execution time Memory
1090520 2024-09-18T12:25:42 Z vjudge1 Game (IOI13_game) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "game.h"

using namespace std;
struct node{
    node *ll=nullptr;
    node *lr=nullptr;
    node *rl=nullptr;
    node *rr=nullptr;
    node *tatko=nullptr;
    long long value=0;
    pair<long long,long long> x;
    pair<long long,long long> y;
};


// trgni voa posle
long long gcd2(long long x,long long y)
{
    if (x%y==0) return y;
    return gcd2(y,x%y);
}

node koren;
void init(long long R,long long C)
{
    koren.x.first =0;
    koren.y.first =0;
    koren.x.second=R;
    koren.y.second=C;
}

void update11(long long r=0,long long c=0,long long v=0,node &n=koren)
{
    //cout<< "ulava u "<<n.x.first<<" "<<n.x.second<< "  "<<n.y.first<<" "<<n.y.second<<endl;
    //system("pause");
    if (n.x.first==n.x.second && n.y.first==n.y.second)
    {
        n.value = v;
        return;
    }

    long long midx = (n.x.second+n.x.first)/2;
    long long midy = (n.y.second+n.y.first)/2;

    if (r>=n.x.first && r<=midx)
    {
        if (c>=n.y.first && c<=midy)
        {
            if (n.ll==nullptr)
            {
                node *nov = new node;
                n.ll = nov;
                nov->x={n.x.first,midx};
                nov->y={n.y.first,midy};
                nov->tatko=&n;
                nov->value = v;
            }
            update1(r,c,v,*n.ll);
            n.ll->value = gcd2(n.ll->value,v);
        }
        if (c<=n.y.second && c>midy)
        {
            if (n.lr==nullptr)
            {
                node *nov = new node;
                n.lr=nov;
                nov->x={n.x.first,midx};
                nov->y={midy+1,n.y.second};
                nov->tatko=&n;
                nov->value = v;
            }
            update1(r,c,v,*n.lr);
            n.lr->value = gcd2(n.lr->value,v);
        }
    }

    if (r<=n.x.second && r>midx)
    {
        if (c>=n.y.first && c<=midy)
        {
            if (n.rl==nullptr)
            {
                node *nov = new node;
                n.rl=nov;
                nov->x={midx+1,n.x.second};
                nov->y={n.y.first,midy};
                nov->tatko=&n;
                nov->value = v;
            }
            update1(r,c,v,*n.rl);
            n.rl->value = gcd2(n.rl->value,v);
        }
        if (c<=n.y.second && c>midy)
        {
            if (n.rr==nullptr)
            {
                node *nov = new node;
                n.rr=nov;
                nov->x={midx+1,n.x.second};
                nov->y={midy+1,n.y.second};
                nov->tatko=&n;
                nov->value = v;
            }
            update1(r,c,v,*n.rr);
            n.rr->value = gcd2(n.rr->value,v);
        }
    }
    if (n.value == 0) n.value=v;
    else n.value = gcd2(n.value,v);
}

long long calculate11(long long lx=0,long long ty=0,long long rx=0,long long by=0,node &n=koren)
{
    if (lx<=n.x.first && rx>=n.x.second && ty<=n.y.first && by>=n.y.second) return n.value;
    long long odg=0;
    long long midx=(n.x.first+n.x.second)/2;
    long long midy=(n.y.first+n.y.second)/2;

    if (lx<=midx && rx>=n.x.first)
    {
        if (ty<=midy && by>=n.y.first && n.ll!=nullptr)
        {
            long long t = calculate1(lx,ty,rx,by,*n.ll);
            if (odg==0) odg = t;
            else odg = gcd2(odg,t);
        }
        if (midy<by && n.y.second>=ty && n.lr!=nullptr)
        {
            long long t = calculate1(lx,ty,rx,by,*n.lr);
            if (odg==0) odg = t;
            else odg = gcd2(odg,t);
        }
    }

    if (midx<rx && n.x.second>=lx)
    {
        if (ty<=midy && by>=n.y.first && n.rl!=nullptr)
        {
            long long t = calculate1(lx,ty,rx,by,*n.rl);
            if (odg==0) odg = t;
            else odg = gcd2(odg,t);
        }
        if (midy<by && n.y.second>=ty && n.rr!=nullptr)
        {
            long long t = calculate1(lx,ty,rx,by,*n.rr);
            if (odg==0) odg = t;
            else odg = gcd2(odg,t);
        }
    }

    return odg;
}

void update1(int P, int Q,long long K)
{
    update(P,Q,K);
}
long long calculate(int P, int Q, int U, int V)
{
    calculate1(P,Q,U,V);
}

Compilation message

game.cpp: In function 'void update11(long long int, long long int, long long int, node&)':
game.cpp:59:13: error: 'update1' was not declared in this scope; did you mean 'update11'?
   59 |             update1(r,c,v,*n.ll);
      |             ^~~~~~~
      |             update11
game.cpp:73:13: error: 'update1' was not declared in this scope; did you mean 'update11'?
   73 |             update1(r,c,v,*n.lr);
      |             ^~~~~~~
      |             update11
game.cpp:91:13: error: 'update1' was not declared in this scope; did you mean 'update11'?
   91 |             update1(r,c,v,*n.rl);
      |             ^~~~~~~
      |             update11
game.cpp:105:13: error: 'update1' was not declared in this scope; did you mean 'update11'?
  105 |             update1(r,c,v,*n.rr);
      |             ^~~~~~~
      |             update11
game.cpp: In function 'long long int calculate11(long long int, long long int, long long int, long long int, node&)':
game.cpp:124:27: error: 'calculate1' was not declared in this scope; did you mean 'calculate11'?
  124 |             long long t = calculate1(lx,ty,rx,by,*n.ll);
      |                           ^~~~~~~~~~
      |                           calculate11
game.cpp:130:27: error: 'calculate1' was not declared in this scope; did you mean 'calculate11'?
  130 |             long long t = calculate1(lx,ty,rx,by,*n.lr);
      |                           ^~~~~~~~~~
      |                           calculate11
game.cpp:140:27: error: 'calculate1' was not declared in this scope; did you mean 'calculate11'?
  140 |             long long t = calculate1(lx,ty,rx,by,*n.rl);
      |                           ^~~~~~~~~~
      |                           calculate11
game.cpp:146:27: error: 'calculate1' was not declared in this scope; did you mean 'calculate11'?
  146 |             long long t = calculate1(lx,ty,rx,by,*n.rr);
      |                           ^~~~~~~~~~
      |                           calculate11
game.cpp: In function 'long long int calculate(int, int, int, int)':
game.cpp:161:5: error: 'calculate1' was not declared in this scope; did you mean 'calculate11'?
  161 |     calculate1(P,Q,U,V);
      |     ^~~~~~~~~~
      |     calculate11
game.cpp:162:1: warning: no return statement in function returning non-void [-Wreturn-type]
  162 | }
      | ^