Submission #949762

# Submission time Handle Problem Language Result Execution time Memory
949762 2024-03-19T16:18:42 Z rainboy 직사각형 게임 (KPI13_game) C++17
1 / 1
1 ms 604 KB
#include <math.h>
#include <stdio.h>

#define eps	1e-9

double abs_(double a) { return a > 0 ? a : -a; }

int main() {
	double alpha, beta, z;
	int a, b, c, d, tmp, first;

	scanf("%d%d%d%d", &a, &b, &c, &d), z = hypot(c, d);
	if (a < b)
		tmp = a, a = b, b = tmp;
	if (c < d)
		tmp = c, c = d, d = tmp;
	alpha = atan2(d, c) * 2;
	first = 0;
	if (b >= z)
		first = 1;
	else if (a * a + b * b < c * c + d * d)
		first = 0;
	else {
		if (b * b <= c * c + d * d) {
			beta = asin((double) b / z);
			if (abs_(z * cos(beta + alpha)) <= a + eps && abs_(z * sin(beta + alpha)) <= b + eps)
				first = 1;
			if (abs_(z * cos(beta - alpha)) <= a + eps && abs_(z * sin(beta - alpha)) <= b + eps)
				first = 1;
		}
		if (a * a <= c * c + d * d) {
			beta = acos((double) a / z);
			if (abs_(z * cos(beta + alpha)) <= a + eps && abs_(z * sin(beta + alpha)) <= b + eps)
				first = 1;
			if (abs_(z * cos(beta - alpha)) <= a + eps && abs_(z * sin(beta - alpha)) <= b + eps)
				first = 1;
		}
	}
	printf(first ? "First\n" : "Second\n");
	return 0;
}

Compilation message

game.cpp: In function 'int main()':
game.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d%d%d%d", &a, &b, &c, &d), z = hypot(c, d);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 428 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 600 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 504 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct