답안 #396518

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
396518 2021-04-30T06:25:34 Z phathnv 게임 (IOI13_game) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#include "game.h"
using ll=long long;
int sz1=1, sz2=1;
 
struct T { ll x; int p, l, r; } X[60000000];
struct seg {
	int N, root;
	seg(const int n) : N(n-1) { root=0; }
	ll get(int l, int r, int s, int e, int i) const {
		if(!i || e<l || r<s) return 0;
		if(l<=s && e<=r) return X[i].x;
		if(~X[i].p) return l<=X[i].p && X[i].p<=r ? X[i].x : 0;
		int m=(s+e)>>1;
		return gcd(get(l, r, s, m, X[i].l), get(l, r, m+1, e, X[i].r));
	}
	ll get(int l, int r) const { return get(l, r, 0, N, root); }
	ll set(int p, ll x, int s, int e, int&i) {
		if(p<s || e<p) return X[i].x;
		if(!i) { X[i=sz1++]={x, p, 0, 0}; return x; }
		if(s==e) return X[i].x=x;
		int m=(s+e)>>1;
		if(~X[i].p) set(X[i].p, X[i].x, s, m, X[i].l), set(X[i].p, X[i].x, m+1, e, X[i].r), X[i].p=-1;
		return X[i].x=gcd(set(p, x, s, m, X[i].l), set(p, x, m+1, e, X[i].r));
	}
	void set(int p, ll x) { set(p, x, 0, N, root); }
};
 
struct T2 { seg* x; int l, r; } Y[4194304];
struct seg2 {
	int N, M, root;
	seg2(int n, int m) : N(n-1), M(m) { root=0; }
	ll get(int l1, int r1, int l2, int r2, int s, int e, int i) const {
		if(!i || e<l1 || r1<s) return 0;
		if(l1<=s && e<=r1) return Y[i].x->get(l2, r2);
		int m=(s+e)>>1;
		return gcd(get(l1, r1, l2, r2, s, m, Y[i].l), get(l1, r1, l2, r2, m+1, e, Y[i].r));
	}
	ll get(int l1, int r1, int l2, int r2) const { return get(l1, r1, l2, r2, 0, N, root); }
	ll set(int p, int q, ll x, int s, int e, int&i) {
		if(p<s || e<p) return i ? Y[i].x->get(q, q) : 0;
		if(!i) Y[i=sz2++].x=new seg(M);
		if(s==e) {
			Y[i].x->set(q, x);
			return x;
		}
		int m=(s+e)>>1;
		ll y=gcd(set(p, q, x, s, m, Y[i].l), set(p, q, x, m+1, e, Y[i].r));
		Y[i].x->set(q, y);
		return y;
	}
	void set(int p, int q, ll x) { set(p, q, x, 0, N, root); }
} *T;
 
void init(int R, int C) {
	T=new seg2(R, C);
}
void update(int P, int Q, ll K) {
	T->set(P, Q, K);
}
ll calculate(int P, int Q, int U, int V) {
	return T->get(P, U, Q, V);
}

Compilation message

game.cpp: In member function 'll seg::get(int, int, int, int, int) const':
game.cpp:16:10: error: 'gcd' was not declared in this scope
   16 |   return gcd(get(l, r, s, m, X[i].l), get(l, r, m+1, e, X[i].r));
      |          ^~~
game.cpp: In member function 'll seg::set(int, ll, int, int, int&)':
game.cpp:25:17: error: 'gcd' was not declared in this scope
   25 |   return X[i].x=gcd(set(p, x, s, m, X[i].l), set(p, x, m+1, e, X[i].r));
      |                 ^~~
game.cpp: In member function 'll seg2::get(int, int, int, int, int, int, int) const':
game.cpp:38:10: error: 'gcd' was not declared in this scope
   38 |   return gcd(get(l1, r1, l2, r2, s, m, Y[i].l), get(l1, r1, l2, r2, m+1, e, Y[i].r));
      |          ^~~
game.cpp: In member function 'll seg2::set(int, int, ll, int, int, int&)':
game.cpp:49:8: error: 'gcd' was not declared in this scope
   49 |   ll y=gcd(set(p, q, x, s, m, Y[i].l), set(p, q, x, m+1, e, Y[i].r));
      |        ^~~