From 3c2f792e1567c36af65be795fc0405cb29f61083 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Mon, 26 Jul 2021 21:40:47 +0800 Subject: [PATCH] =?UTF-8?q?HDU-6080=20=E5=BA=A6=E5=BA=A6=E7=86=8A=E4=BF=9D?= =?UTF-8?q?=E6=8A=A4=E6=9D=91=E5=BA=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://vjudge.net/solution/31950692 --- vjudge/problem/HDU/6080/6080.cpp | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 vjudge/problem/HDU/6080/6080.cpp diff --git a/vjudge/problem/HDU/6080/6080.cpp b/vjudge/problem/HDU/6080/6080.cpp new file mode 100644 index 00000000..6a369f2b --- /dev/null +++ b/vjudge/problem/HDU/6080/6080.cpp @@ -0,0 +1,69 @@ +#include + +using namespace std; + +int n, m, ans, dp[505][505]; + +struct node { + int x, y; + + node() {} + node(int _x, int _y) { + x = _x; + y = _y; + } + node operator-(node B) { + return node(x - B.x, y - B.y); + } +} hou[505], fri[505]; + +inline int det(node A, node B) { + return A.x * B.y - A.y * B.x; +} + +int main() { + while (cin >> n) { + for (int i = 1; i <= n; i++) { + cin >> hou[i].x >> hou[i].y; + } + cin >> m; + for (int i = 1; i <= m; i++) { + cin >> fri[i].x >> fri[i].y; + } + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= m; j++) { + dp[i][j] = -1; + if (i == j) continue; + bool ok = true; + for (int k = 1; k <= n; k++) + if (det(hou[k] - fri[i], fri[j] - fri[i]) > 0) { + ok = false; + break; + } + if (ok) { + dp[i][j] = 1; + } + } + } + for (int k = 1; k <= m; k++) { + for (int i = 1; i <= m; i++) { + if (dp[i][k] == -1) continue; + for (int j = 1; j <= m; j++) { + if (dp[k][j] == -1) continue; + dp[i][j] = dp[i][j] == -1 ? dp[i][k] + dp[k][j] : min(dp[i][j], dp[i][k] + dp[k][j]); + } + } + } + ans = -1; + for (int i = 1; i <= m; i++) { + if (dp[i][i] == -1) continue; + ans = ans == -1 ? dp[i][i] : min(ans, dp[i][i]); + } + if (ans == -1) { + cout << "ToT" << endl; + } else { + cout << m - ans << endl; + } + } + return 0; +}