제출 #82931

#제출 시각아이디문제언어결과실행 시간메모리
82931SaboonTriangles (CEOI18_tri)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e4 + 100;
const int SQRT = 201;
int first = 1, m = 3;
int pre[maxn], nex[maxn], nexsqrt[maxn];

void remove (int fi, int mid, int se) {
	m --;
	pre[se] = fi, nex[fi] = se;
	int k = SQRT;
	while (k --) {
		if (nexsqrt[fi] != -1) {
			nexsqrt[fi] = nex[nexsqrt[fi]];
			if (nexsqrt[fi] == first)
				nexsqrt[fi] = -1;
		}
		fi = pre[fi];
	}
	if (mid == first)
		se = first;
}

void insert (int fi, int mid, int se) {
	m ++;
	nex[fi] = mid, nex[mid] = se;
	pre[se] = mid, pre[mid] = fi;
	
	int k = SQRT;
	nexsqrt[mid] = nexsqrt[fi];
	while (k --) {
		if (nexsqrt[fi] != -1)
			nexsqrt[fi] = pre[nexsqrt[fi]];
		mid = pre[mid];
	}
}

int get (int idx) {
	idx %= m;
	int tmp = first;
	while (idx > 0) {
		if (idx >= SQRT) {
			tmp = nexsqrt[tmp];
			idx -= SQRT;
		}
		else {
			tmp = nex[tmp];
			idx --;
		}
	}
	return tmp;
}

void build_first () {
	if (is_clockwise (1, 2, 3)) {
		nex[1] = 2;
		nex[2] = 3;
		nex[3] = 1;
		pre[1] = 3;
		pre[2] = 1;
		pre[3] = 2;
	}
	else {
		nex[1] = 3;
		nex[3] = 2;
		nex[2] = 1;
		pre[1] = 2;
		pre[2] = 3;
		pre[3] = 1;
	}
}

int main() {
	ios::sync_with_stdio(false);
	memset (nexsqrt, -1, sizeof nexsqrt);
	int n = get_n ();
	build_first ();
	for (int i = 4; i <= n; i++) {
		int lo = 0, hi = m;
		while (hi - lo > 1) {
			int mid = (hi + lo) >> 1;
			int x = get (lo), y = get (mid);
			if (!is_clockwise (x, y, i))
				hi = mid;
			else
				lo = mid;
		}

		int x = get (lo), y = get (hi);
		if (is_clockwise (x, y, i))
			continue;
		
		insert (get (lo), i, get (hi));

		while (!is_clockwise (i, nex[i], nex[nex[i]])) {
			remove (i, nex[i], nex[nex[i]]);
		}
		while (!is_clockwise (pre[pre[i]], pre[i], i)) {
			remove (pre[pre[i]], pre[i], i);
		}
	}
	give_answer (m);
}

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

tri.cpp: In function 'void build_first()':
tri.cpp:55:6: error: 'is_clockwise' was not declared in this scope
  if (is_clockwise (1, 2, 3)) {
      ^~~~~~~~~~~~
tri.cpp:55:6: note: suggested alternative: 'funlockfile'
  if (is_clockwise (1, 2, 3)) {
      ^~~~~~~~~~~~
      funlockfile
tri.cpp: In function 'int main()':
tri.cpp:76:10: error: 'get_n' was not declared in this scope
  int n = get_n ();
          ^~~~~
tri.cpp:76:10: note: suggested alternative: 'get'
  int n = get_n ();
          ^~~~~
          get
tri.cpp:83:9: error: 'is_clockwise' was not declared in this scope
    if (!is_clockwise (x, y, i))
         ^~~~~~~~~~~~
tri.cpp:83:9: note: suggested alternative: 'funlockfile'
    if (!is_clockwise (x, y, i))
         ^~~~~~~~~~~~
         funlockfile
tri.cpp:90:7: error: 'is_clockwise' was not declared in this scope
   if (is_clockwise (x, y, i))
       ^~~~~~~~~~~~
tri.cpp:90:7: note: suggested alternative: 'funlockfile'
   if (is_clockwise (x, y, i))
       ^~~~~~~~~~~~
       funlockfile
tri.cpp:95:11: error: 'is_clockwise' was not declared in this scope
   while (!is_clockwise (i, nex[i], nex[nex[i]])) {
           ^~~~~~~~~~~~
tri.cpp:95:11: note: suggested alternative: 'funlockfile'
   while (!is_clockwise (i, nex[i], nex[nex[i]])) {
           ^~~~~~~~~~~~
           funlockfile
tri.cpp:98:11: error: 'is_clockwise' was not declared in this scope
   while (!is_clockwise (pre[pre[i]], pre[i], i)) {
           ^~~~~~~~~~~~
tri.cpp:98:11: note: suggested alternative: 'funlockfile'
   while (!is_clockwise (pre[pre[i]], pre[i], i)) {
           ^~~~~~~~~~~~
           funlockfile
tri.cpp:102:2: error: 'give_answer' was not declared in this scope
  give_answer (m);
  ^~~~~~~~~~~