Submission #306438

# Submission time Handle Problem Language Result Execution time Memory
306438 2020-09-25T15:16:55 Z Temmie Game (IOI13_game) C++17
Compilation error
0 ms 0 KB
#include "game.h"
#include <bits/stdc++.h>

typedef long long ll;

const ll size = 1073741824;

struct Node {
	
	Node* tl, * tr, * bl, * br;
	
	ll topLx, topLy, recSize;
	
	ll valu;
	
	Node(ll X, ll Y, ll recsize) :
	tl(nullptr), tr(nullptr), bl(nullptr), br(nullptr),
	topLx(X), topLy(Y), recSize(recsize),
	valu(0)
	{ }
	
	~Node() {
		if (tl) delete(tl);
		if (tl) delete(tr);
		if (bl) delete(bl);
		if (br) delete(br);
	}
	
	void update(ll x, ll y, ll val) {
		if (x < topLx || x >= topLx + recSize || y < topLy || y >= topLy + recSize) return;
		if (recSize == 1LL) { valu = val; return; }
		ll xmid = (recSize + topLx + topLx) >> 1LL;
		ll ymid = (recSize + topLy + topLy) >> 1LL;
		if (!tl) tl = new Node(topLx, topLy, recSize >> 1LL);
		if (!bl) bl = new Node(topLx, ymid, recSize >> 1LL);
		if (!tr) tr = new Node(xmid, topLy, recSize >> 1LL);
		if (!br) br = new Node(xmid, ymid, recSize >> 1LL);
		tl->update(x, y, val);
		bl->update(x, y, val);
		tr->update(x, y, val);
		br->update(x, y, val);
		valu = gcd2(tl->valu, gcd2(tr->valu, gcd2(bl->valu, br->valu)));
	}
	
	ll get(ll xl, ll yl, ll xr, ll yr) {
		if (xr <= topLx || xl >= topLx + recSize || yr <= topLy || yl >= topLx + recSize) return 0;
		if (xl <= topLx && xr >= topLx + recSize && yl <= topLy && yr >= topLy + recSize) return valu;
		return gcd2(tl->get(xl, yl, xr, yr), gcd2(tr->get(xl, yl, xr, yr), gcd2(bl->get(xl, yl, xr, yr), br->get(xl, yl, xr, yr))));
	}
	
};

Node* head = nullptr;

void init(int r, int c) { head = new Node(0, 0, size); }

void update(int r, int c, ll val) { head->update(c, r, val); }

ll calculate(int tr, int tl, int br, int bl) { return head->get(tl, tr, bl + 1, br + 1); }

Compilation message

game.cpp: In member function 'void Node::update(ll, ll, ll)':
game.cpp:42:40: error: 'gcd2' was not declared in this scope
   42 |   valu = gcd2(tl->valu, gcd2(tr->valu, gcd2(bl->valu, br->valu)));
      |                                        ^~~~
game.cpp:42:25: error: 'gcd2' was not declared in this scope
   42 |   valu = gcd2(tl->valu, gcd2(tr->valu, gcd2(bl->valu, br->valu)));
      |                         ^~~~
game.cpp:42:10: error: 'gcd2' was not declared in this scope
   42 |   valu = gcd2(tl->valu, gcd2(tr->valu, gcd2(bl->valu, br->valu)));
      |          ^~~~
game.cpp: In member function 'll Node::get(ll, ll, ll, ll)':
game.cpp:48:70: error: 'gcd2' was not declared in this scope
   48 |   return gcd2(tl->get(xl, yl, xr, yr), gcd2(tr->get(xl, yl, xr, yr), gcd2(bl->get(xl, yl, xr, yr), br->get(xl, yl, xr, yr))));
      |                                                                      ^~~~
game.cpp:48:40: error: 'gcd2' was not declared in this scope
   48 |   return gcd2(tl->get(xl, yl, xr, yr), gcd2(tr->get(xl, yl, xr, yr), gcd2(bl->get(xl, yl, xr, yr), br->get(xl, yl, xr, yr))));
      |                                        ^~~~
game.cpp:48:10: error: 'gcd2' was not declared in this scope
   48 |   return gcd2(tl->get(xl, yl, xr, yr), gcd2(tr->get(xl, yl, xr, yr), gcd2(bl->get(xl, yl, xr, yr), br->get(xl, yl, xr, yr))));
      |          ^~~~