Universal Cup Judging System

Universal Cup

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓
统计

Ein Polygon $P_1$ enthält ein Polygon $P_2$, wenn jeder Punkt innerhalb oder auf dem Rand von $P_2$ auch innerhalb oder auf dem Rand von $P_1$ liegt. Ein Polygon $P_1$ enthält $P_2$ strikt, wenn jeder Punkt innerhalb oder auf dem Rand von $P_2$ strikt im Inneren von $P_1$ liegt (kein Punkt auf dem Rand).

Panda hat zwei konvexe Polygone, $P$ und $Q$. Das Polygon $P$ hat $n$ Eckpunkte und das Polygon $Q$ hat $m$ Eckpunkte. Es wird garantiert, dass $Q$ strikt in $P$ enthalten ist.

Du sollst Panda dabei helfen, die Gesamtanzahl der Möglichkeiten zu bestimmen, genau $3$ verschiedene Eckpunkte aus dem Polygon $P$ auszuwählen, die ein Dreieck $P_\Delta$ bilden, sodass $P_\Delta$ das Polygon $Q$ (nicht unbedingt strikt) enthält.

Figure 1

Eingabe

Die erste Zeile enthält eine einzelne ganze Zahl $T$ ($1 \le T \le 1000$), die Anzahl der Testfälle.

Für jeden Testfall enthält die erste Zeile eine ganze Zahl $n$ ($3 \le n \le 3 \cdot 10^5$), die Anzahl der Eckpunkte von $P$.

In den nächsten $n$ Zeilen enthält jede Zeile zwei ganze Zahlen $x, y$ ($|x|, |y| \le 10^9$), die Koordinaten der Eckpunkte von $P$. Es wird garantiert, dass die Eckpunkte gegen den Uhrzeigersinn angegeben sind und keine drei Eckpunkte kollinear sind.

Die nächste Zeile enthält eine ganze Zahl $m$ ($3 \le m \le 3 \cdot 10^5$), die Anzahl der Eckpunkte von $Q$.

In den nächsten $m$ Zeilen enthält jede Zeile zwei ganze Zahlen $x, y$ ($|x|, |y| \le 10^9$), die Koordinaten der Eckpunkte von $Q$. Es wird garantiert, dass die Eckpunkte gegen den Uhrzeigersinn angegeben sind, keine drei Eckpunkte kollinear sind und $Q$ strikt in $P$ enthalten ist.

Es wird garantiert, dass sowohl $\sum n$ als auch $\sum m$ über alle Testfälle hinweg $5 \cdot 10^5$ nicht überschreiten.

Ausgabe

Gib für jeden Testfall eine ganze Zahl in einer einzelnen Zeile aus, die die Antwort darstellt.

Beispiele

Eingabe 1

3
6
-5 0
-4 -4
0 -4
3 1
2 5
-3 4
4
-2 1
-2 0
0 0
0 1
6
-5 0
-4 -4
0 -4
3 1
2 5
-3 4
4
-1 1
-1 0
0 0
0 1
7
1 -3
4 -1
5 0
1 4
0 4
-1 0
0 -2
3
0 0
2 0
0 2

Ausgabe 1

2
4
6

Hinweis

Für das erste Beispiel ist, wie in der Abbildung gezeigt, das Polygon $P$ gleich $ABCDEF$ und das Polygon $Q$ gleich $GHIJ$. Die Dreiecke $\triangle ACE$ und $\triangle BDF$ sind diejenigen, die $Q$ enthalten.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.