제출 #898002

#제출 시각아이디문제언어결과실행 시간메모리
898002Faisal_Saqib게임 (IOI13_game)C++17
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <numeric>
using namespace std;
const int N=2000;
struct SegmentTree
{
	long long gdc=0;
	int s,e;
	SegmentTree* next[2];
	SegmentTree(int l,int r)
	{
		s=l;
		e=r;
		next[0]=next[1]=NULL;
	}
	long long get(int& l,int& r)
	{
		if(e<l or r<s)
			return 0;
		if(l<=s and e<=r)
			return gdc;
		long long ans=0;
		if(next[0]!=NULL)
			ans=gcd(ans,next[0]->get(l,r));
		if(next[1]!=NULL)
			ans=gcd(ans,next[1]->get(l,r));
		return ans;
	}
	void Update(int& l,long long& val)
	{
		if(s==e)
		{
			if(s==l)
				gdc=val;
			return;
		}
		if(l<=((s+e)/2))
		{
			if(next[0]==NULL)
				next[0]=new SegmentTree(s,(s+e)/2);
			next[0]->Update(l,val);
		}
		else
		{
			if(next[1]==NULL)
				next[1]=new SegmentTree(1+((s+e)/2),e);
			next[1]->Update(l,val);
		}
		gdc=0;
		if(next[0]!=NULL)
			gdc=gcd(next[0]->gdc,gdc);
		if(next[1]!=NULL)
			gdc=gcd(next[1]->gdc,gdc);
	}
};
SegmentTree* st[N];
int R,C;
void init(int r, int c)
{
	R=r;
	C=c;
}
void update(int p, int q, long long k)
{
	if(st[p]==NULL)
	{
		st[p]=new SegmentTree(0,C-1);
	}
	st[p]->Update(q,k);
}
long long calculate(int P, int Q, int U, int V)
{
	long long ans=0;
	for(;P<=U;P++)
	{
		if(st[P]!=NULL)
			ans=gcd(ans,st[P]->get(Q,V));
		if(ans==1)
	  		return 1;
	}
	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccKWJV3H.o: in function `main':
grader.c:(.text.startup+0x6b): undefined reference to `init'
/usr/bin/ld: grader.c:(.text.startup+0xd0): undefined reference to `calculate'
/usr/bin/ld: grader.c:(.text.startup+0x13e): undefined reference to `update'
collect2: error: ld returned 1 exit status