제출 #78950

#제출 시각아이디문제언어결과실행 시간메모리
78950aminraTriangles (CEOI18_tri)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)107;
const int infint = (int)1e9;
int n;
vector<int> u, d, ans;
/*int get_n()
{
	int x;
	cin >> x;
	return x;
}
int is_clockwise(int x, int y, int z)
{
	cout << x << " " << y << " " << z << endl;
	int ans;
	cin >> ans;
	return ans;
}
void give_answer(int t)
{
	cout << t << endl;
	return;
}*/
bool cw(int i, int j)
{
	return is_clockwise(1, i, j);
}
bool ccw(int i, int j)
{
	return !is_clockwise(1, i, j);
}
vector<int> convex(vector<int> v)
{
	vector<int> ans;
	for (auto u : v)
	{
		while(ans.size() >= 2 && is_clockwise(ans[ans.size() - 2], ans.back(), u))
			ans.pop_back();
		ans.push_back(u);
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	n = get_n();
	for (int i = 3; i <= n; i++)
		if(is_clockwise(1, 2, i))
			d.push_back(i);
		else
			u.push_back(i);
			
	sort(d.begin(), d.end(), ccw);
	sort(u.begin(), u.end(), ccw);
	d.push_back(2);
	u.push_back(1);
	
	d = convex(d), u = convex(u);
	for (auto x : d)
		ans.push_back(x);
	for (auto x : u)
		ans.push_back(x);
	/*for (auto x : ans)
		cout << x << " ";
	cout << endl;
	ans = convex(ans);
	for (auto x : ans)
		cout << x << " ";
	cout << endl;*/
	
	
	deque<int> qs;
	for (auto x : ans)
		qs.push_back(x);
	bool did = false;
	while(!did)
	{
		did = 1;
		int a = qs.back(); qs.pop_back();
		if(is_clockwise(qs.back(), a, qs.front()))
			did = 0;
		else
			qs.push_back(a);
		a = qs.front();
		qs.pop_front();
		if(!is_clockwise(qs.front(), a, qs.back()))
			did = 0;
		else
			qs.push_front(a);
	}
	give_answer(qs.size());
}

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

tri.cpp: In function 'bool cw(int, int)':
tri.cpp:30:9: error: 'is_clockwise' was not declared in this scope
  return is_clockwise(1, i, j);
         ^~~~~~~~~~~~
tri.cpp:30:9: note: suggested alternative: 'funlockfile'
  return is_clockwise(1, i, j);
         ^~~~~~~~~~~~
         funlockfile
tri.cpp: In function 'bool ccw(int, int)':
tri.cpp:34:10: error: 'is_clockwise' was not declared in this scope
  return !is_clockwise(1, i, j);
          ^~~~~~~~~~~~
tri.cpp:34:10: note: suggested alternative: 'funlockfile'
  return !is_clockwise(1, i, j);
          ^~~~~~~~~~~~
          funlockfile
tri.cpp: In function 'std::vector<int> convex(std::vector<int>)':
tri.cpp:41:28: error: 'is_clockwise' was not declared in this scope
   while(ans.size() >= 2 && is_clockwise(ans[ans.size() - 2], ans.back(), u))
                            ^~~~~~~~~~~~
tri.cpp:41:28: note: suggested alternative: 'funlockfile'
   while(ans.size() >= 2 && is_clockwise(ans[ans.size() - 2], ans.back(), u))
                            ^~~~~~~~~~~~
                            funlockfile
tri.cpp: In function 'int main()':
tri.cpp:51:6: error: 'get_n' was not declared in this scope
  n = get_n();
      ^~~~~
tri.cpp:51:6: note: suggested alternative: 'getwc'
  n = get_n();
      ^~~~~
      getwc
tri.cpp:53:6: error: 'is_clockwise' was not declared in this scope
   if(is_clockwise(1, 2, i))
      ^~~~~~~~~~~~
tri.cpp:53:6: note: suggested alternative: 'funlockfile'
   if(is_clockwise(1, 2, i))
      ^~~~~~~~~~~~
      funlockfile
tri.cpp:85:6: error: 'is_clockwise' was not declared in this scope
   if(is_clockwise(qs.back(), a, qs.front()))
      ^~~~~~~~~~~~
tri.cpp:85:6: note: suggested alternative: 'funlockfile'
   if(is_clockwise(qs.back(), a, qs.front()))
      ^~~~~~~~~~~~
      funlockfile
tri.cpp:91:7: error: 'is_clockwise' was not declared in this scope
   if(!is_clockwise(qs.front(), a, qs.back()))
       ^~~~~~~~~~~~
tri.cpp:91:7: note: suggested alternative: 'funlockfile'
   if(!is_clockwise(qs.front(), a, qs.back()))
       ^~~~~~~~~~~~
       funlockfile
tri.cpp:96:2: error: 'give_answer' was not declared in this scope
  give_answer(qs.size());
  ^~~~~~~~~~~