답안 #598992

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598992 2022-07-19T08:44:09 Z 장태환(#8458) The Forest of Fangorn (CEOI14_fangorn) C++17
100 / 100
2848 ms 1256 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({ atan2(camp[j][0] - tree[i][0],camp[j][1] - tree[i][1]),j+1 });
		}
		t.push_back({ atan2(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 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 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 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 224 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 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 106 ms 340 KB Output is correct
5 Correct 22 ms 340 KB Output is correct
6 Correct 363 ms 392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 666 ms 476 KB Output is correct
2 Correct 2325 ms 1164 KB Output is correct
3 Correct 2848 ms 1220 KB Output is correct
4 Correct 2474 ms 1256 KB Output is correct