Submission #226268

# Submission time Handle Problem Language Result Execution time Memory
226268 2020-04-23T09:03:58 Z dolphingarlic Dragon 2 (JOI17_dragon2) C++14
100 / 100
2580 ms 2420 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

struct Point { ll x, y; } A, B;

bool ccw(Point X, Point Y, Point Z) { return (X.x - Y.x) * (Z.y - Y.y) <= (X.y - Y.y) * (Z.x - Y.x); }

vector<Point> by_t[30001];

int main() {
	int n, m, q, x, y;
	scanf("%d %d", &n, &m);
	while (n--) {
		scanf("%lld %lld %d", &A.x, &A.y, &q);
		by_t[q].push_back(A);
	}
	scanf("%lld %lld %lld %lld\n%d", &A.x, &A.y, &B.x, &B.y, &q);
	while (q--) {
		scanf("%d %d", &x, &y);
		m = 0;
		for (Point i : by_t[x]) for (Point j : by_t[y]) {
			if (ccw(i, A, B)) m += (ccw(i, A, j) && ccw(j, B, i));
			else m += (ccw(j, A, i) && ccw(i, B, j));
		}
		printf("%d\n", m);
	}
	return 0;
}

Compilation message

dragon2.cpp: In function 'int main()':
dragon2.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
dragon2.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %d", &A.x, &A.y, &q);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dragon2.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld %lld\n%d", &A.x, &A.y, &B.x, &B.y, &q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dragon2.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1152 KB Output is correct
2 Correct 22 ms 1152 KB Output is correct
3 Correct 31 ms 1152 KB Output is correct
4 Correct 53 ms 1272 KB Output is correct
5 Correct 47 ms 1280 KB Output is correct
6 Correct 7 ms 1152 KB Output is correct
7 Correct 7 ms 1152 KB Output is correct
8 Correct 11 ms 1152 KB Output is correct
9 Correct 11 ms 1152 KB Output is correct
10 Correct 11 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1022 ms 1712 KB Output is correct
2 Correct 1779 ms 1748 KB Output is correct
3 Correct 58 ms 1920 KB Output is correct
4 Correct 21 ms 1792 KB Output is correct
5 Correct 23 ms 1792 KB Output is correct
6 Correct 1012 ms 1780 KB Output is correct
7 Correct 961 ms 1780 KB Output is correct
8 Correct 508 ms 1780 KB Output is correct
9 Correct 475 ms 1780 KB Output is correct
10 Correct 532 ms 1776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1152 KB Output is correct
2 Correct 22 ms 1152 KB Output is correct
3 Correct 31 ms 1152 KB Output is correct
4 Correct 53 ms 1272 KB Output is correct
5 Correct 47 ms 1280 KB Output is correct
6 Correct 7 ms 1152 KB Output is correct
7 Correct 7 ms 1152 KB Output is correct
8 Correct 11 ms 1152 KB Output is correct
9 Correct 11 ms 1152 KB Output is correct
10 Correct 11 ms 1152 KB Output is correct
11 Correct 1022 ms 1712 KB Output is correct
12 Correct 1779 ms 1748 KB Output is correct
13 Correct 58 ms 1920 KB Output is correct
14 Correct 21 ms 1792 KB Output is correct
15 Correct 23 ms 1792 KB Output is correct
16 Correct 1012 ms 1780 KB Output is correct
17 Correct 961 ms 1780 KB Output is correct
18 Correct 508 ms 1780 KB Output is correct
19 Correct 475 ms 1780 KB Output is correct
20 Correct 532 ms 1776 KB Output is correct
21 Correct 1049 ms 1772 KB Output is correct
22 Correct 1825 ms 1784 KB Output is correct
23 Correct 1898 ms 2296 KB Output is correct
24 Correct 585 ms 2172 KB Output is correct
25 Correct 77 ms 2040 KB Output is correct
26 Correct 66 ms 2040 KB Output is correct
27 Correct 29 ms 1920 KB Output is correct
28 Correct 27 ms 2048 KB Output is correct
29 Correct 2580 ms 2420 KB Output is correct
30 Correct 86 ms 1908 KB Output is correct
31 Correct 65 ms 1908 KB Output is correct
32 Correct 80 ms 2040 KB Output is correct
33 Correct 543 ms 2168 KB Output is correct
34 Correct 65 ms 2044 KB Output is correct
35 Correct 65 ms 1976 KB Output is correct
36 Correct 69 ms 2040 KB Output is correct
37 Correct 66 ms 2044 KB Output is correct
38 Correct 897 ms 2168 KB Output is correct
39 Correct 722 ms 2168 KB Output is correct
40 Correct 577 ms 2168 KB Output is correct
41 Correct 2261 ms 2100 KB Output is correct
42 Correct 1505 ms 2020 KB Output is correct
43 Correct 1159 ms 2168 KB Output is correct
44 Correct 1550 ms 1660 KB Output is correct
45 Correct 744 ms 1664 KB Output is correct
46 Correct 504 ms 1916 KB Output is correct
47 Correct 1102 ms 1816 KB Output is correct
48 Correct 710 ms 1956 KB Output is correct
49 Correct 422 ms 2296 KB Output is correct