답안 #598990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598990 2022-07-19T08:43:43 Z 장태환(#8458) The Forest of Fangorn (CEOI14_fangorn) C++17
80 / 100
3000 ms 996 KB
#include <bits/stdc++.h>
using namespace std;
int w, h;
int x, y;
int tree[2100][2];
int camp[10100][2];
int arr[10100];
int val[10100];
int ans[10100];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> w >> h >> x >> y;
	int C;
	cin >> C;
	int i;
	for (i = 0; i < C; i++)
	{
		cin >> camp[i][0] >> camp[i][1];
		ans[i + 1] = 1;
	}
	int N;
	cin >> N;
	for (i = 0; i < N;i++)
	{
		cin >> tree[i][0] >> tree[i][1];

	}
	for (i = 0; i < N; i++)
	{
		vector<pair<double, int>>t;
		int j;
		for (j = 0; j < N; j++)
		{
			if (j == i)
				continue;
			t.push_back({ atan2(-tree[j][0] + tree[i][0],-tree[j][1] + tree[i][1]),-1 });
		}
		for (j = 0; j < C; j++)
		{
			t.push_back({ atan2l(camp[j][0] - tree[i][0],camp[j][1] - tree[i][1]),j+1 });
		}
		t.push_back({ atan2l(x - tree[i][0],y - tree[i][1]),0 });
		sort(t.begin(), t.end());
		int r = 0;
		for (j = 0; j < t.size(); j++)
		{
			if (t[j].second < 0)
				r++;
			else
				val[t[j].second] = r%(N-1);
		}
		for (j = 1; j <= C; j++)
		{
			if (val[j] != val[0])
				ans[j] = 0;
		}
	}
	vector<int>x;
	for (i = 1; i <= C; i++)
		if(ans[i])
			x.push_back(i);
	cout << x.size()<<'\n';
	for (i = 0; i < x.size(); i++)
		cout << x[i] << ' ';
}

Compilation message

fangorn.cpp: In function 'int main()':
fangorn.cpp:47:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for (j = 0; j < t.size(); j++)
      |               ~~^~~~~~~~~~
fangorn.cpp:65:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |  for (i = 0; i < x.size(); i++)
      |              ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 107 ms 360 KB Output is correct
5 Correct 19 ms 340 KB Output is correct
6 Correct 364 ms 396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 741 ms 472 KB Output is correct
2 Execution timed out 3075 ms 996 KB Time limit exceeded
3 Halted 0 ms 0 KB -