Submission #137280

# Submission time Handle Problem Language Result Execution time Memory
137280 2019-07-27T11:43:32 Z TuGSGeReL Game (IOI13_game) C++17
Compilation error
0 ms 0 KB
#include "game.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;

int rr, cc;
unordered_map <int, unordered_map<int, ll> > sgx;
unordered_map <int, int> which;

long long gcd2(long long X, long long Y) {
    long long tmp;
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
}

void upd(int node, int l, int r)
{
	if ( l == r )
	{
		which[l] = node;
		return;
	}
	
	int mid = (l + r) >> 1;
	upd(node << 1, l, mid);
	upd((node << 1) + 1, mid + 1, r);
}

void init(ll R, ll C) {
	rr = R;
	cc = C;
	upd(1, 1, R);
}

void updy(int node, int l, int r, int idx, ll d, int whi)
{
	if ( l == r && r == idx )
	{
		sgx[whi][node] = d;
		
		do{
			whi >>= 1;
			sgx[whi][node] = gcd2(sgx[whi << 1][node], sgx[(whi << 1) + 1][node]);
		}while(whi > 1);
		
		return;
	}
	
	int mid = (l + r) >> 1;
	
	if ( idx <= mid )
		updy(node << 1, l, mid, idx, d, whi);
	
	else
		updy((node << 1) + 1, mid + 1, r, idx, d, whi);
	
	sgx[whi][node] = gcd2(sgx[whi][node << 1], sgx[whi][(node << 1) + 1]);
	
	do{
		whi >>= 1;
		sgx[whi][node] = gcd2(sgx[whi << 1][node], sgx[(whi << 1) + 1][node]);
	}while(whi > 1);
}


ll lqu(int node, int l, int r, int L, int R, int whi)
{
	if ( l > R || r < L )
		return 0;
		
	if ( l >= L && r <= R )
		return sgx[whi][node];
	
	int mid = (l + r) >> 1;
	
	return gcd2(lqu(node << 1, l, mid, L, R, whi), lqu((node << 1) + 1, mid + 1, r, L, R, whi));
}

ll query (int node, int l, int r, int lx, int ly, int rx, int ry)
{
	if ( l > rx || r < lx )
		return 0;
	
	if ( l >= lx && r <= rx )
		return lqu(1, 1, cc, ly, ry, node);
	
	int mid = (l + r) >> 1;
	
	return gcd2(query(node << 1, l, mid, lx, ly, rx, ry), query((node << 1) + 1, mid + 1, r, lx, ly, rx, ry));
}

inline void update(int P, int Q, ll K) {
	updy(1, 1, cc, Q + 1, K, which[P + 1]);
}

inline ll calculate(int P, int Q, int U, int V) {
	return query(1, 1, rr, P + 1, Q + 1, U + 1, V + 1);
}

Compilation message

grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
/tmp/ccCXpPlF.o: In function `main':
grader.c:(.text.startup+0x5d): undefined reference to `init'
grader.c:(.text.startup+0xb8): undefined reference to `calculate'
grader.c:(.text.startup+0x122): undefined reference to `update'
collect2: error: ld returned 1 exit status