Submission #20202

# Submission time Handle Problem Language Result Execution time Memory
20202 2016-03-14T08:16:18 Z taehoon1018 초록색 삼각형 (YDX13_green) C++
0 / 1
2087 ms 0 KB
#include <iostream>
#include <iomanip>
using namespace std;
typedef struct coord
{
	double x, y;
};

double area(coord *a, coord *b, coord *c)
{
	double res = 0;
	res += a->x*b->y;
	res += b->x*c->y;
	res += c->x*a->y;
	res -= b->x*a->y;
	res -= c->x*b->y;
	res -= a->x*c->y;

	if (res < 0)
		return -res;
	return res;
}

int main(void)
{
	coord p[2000];
	int N = 0;
	int a = 0, b = 1, c = 2;
	double res = 0;
	cin >> N;
	if (N < 3)
	{
		cout << "0";
		return 0;
	}
	for (int i = 0; i < N; i++)
		cin >> p[i].x >> p[i].y;
	while (a != N - 3)
	{
		res += area(p+a, p+b, p+c);
		if (c == N-1)
		{
			if (b == N - 2)
			{
				if (a == N - 3)
					break;
				else
				{
					a++;
					b = a + 1;
					c = a + 2;
				}
			}
			else
			{
				b++;
				c = b + 1;
			}
		}
		else
			c++;
	}
	res += area(p + a, p + b, p + c);
	res *= 3;
	res /= N;
	res /= N - 1;
	res /= N - 2;
	cout << setprecision(12) << res;
}

Compilation message

C.cpp:7:1: warning: 'typedef' was ignored in this declaration
 };
 ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 0 KB Output is correct
2 Correct 1 ms 0 KB Output is correct
3 Correct 1 ms 0 KB Output is correct
4 Correct 1 ms 0 KB Output is correct
5 Correct 2 ms 0 KB Output is correct
6 Correct 1 ms 0 KB Output is correct
7 Correct 1 ms 0 KB Output is correct
8 Correct 1 ms 0 KB Output is correct
9 Correct 1 ms 0 KB Output is correct
10 Correct 1 ms 0 KB Output is correct
11 Correct 932 ms 0 KB Output is correct
12 Execution timed out 2081 ms 0 KB Time limit exceeded
13 Correct 1268 ms 0 KB Output is correct
14 Execution timed out 2073 ms 0 KB Time limit exceeded
15 Correct 361 ms 0 KB Output is correct
16 Execution timed out 2083 ms 0 KB Time limit exceeded
17 Correct 147 ms 0 KB Output is correct
18 Correct 627 ms 0 KB Output is correct
19 Correct 1278 ms 0 KB Output is correct
20 Correct 2 ms 0 KB Output is correct
21 Execution timed out 2071 ms 0 KB Time limit exceeded
22 Execution timed out 2076 ms 0 KB Time limit exceeded
23 Execution timed out 2069 ms 0 KB Time limit exceeded
24 Execution timed out 2084 ms 0 KB Time limit exceeded
25 Execution timed out 2084 ms 0 KB Time limit exceeded
26 Execution timed out 2076 ms 0 KB Time limit exceeded
27 Execution timed out 2087 ms 0 KB Time limit exceeded
28 Execution timed out 2080 ms 0 KB Time limit exceeded
29 Execution timed out 2081 ms 0 KB Time limit exceeded
30 Execution timed out 2086 ms 0 KB Time limit exceeded
31 Incorrect 1 ms 0 KB Output isn't correct