From da736e12d94e31d0256dc5abcbc10c3aa115f0f3 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Fri, 7 Aug 2020 00:55:30 +0800 Subject: [PATCH] =?UTF-8?q?P1789=20=E3=80=90Mc=E7=94=9F=E5=AD=98=E3=80=91?= =?UTF-8?q?=E6=8F=92=E7=81=AB=E6=8A=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R36511988 --- problem/P1789/P1789.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 problem/P1789/P1789.cpp diff --git a/problem/P1789/P1789.cpp b/problem/P1789/P1789.cpp new file mode 100644 index 00000000..869e8946 --- /dev/null +++ b/problem/P1789/P1789.cpp @@ -0,0 +1,31 @@ +#include + +using namespace std; +int n, m, k, x, y, o, p, ans = 0; +int dx1[13] = {2, 0, -2, 0, 1, 1, 1, 0, 0, 0, -1, -1, -1}; +int dy1[13] = {0, 2, 0, -2, 0, 1, -1, 1, 0, -1, 0, 1, -1}; +int dx2[25] = {-2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2}; +int dy2[25] = {-2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, + 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2}; +int main() { + cin >> n >> m >> k; + int a[n + 5][n + 5]; + memset(a, 0, sizeof(a)); + for (int i = 1; i <= m; i++) { + cin >> x >> y; + for (int j = 0; j < 13; j++) + a[x + dx1[j]][y + dy1[j]] = 1; + } + for (int i = 1; i <= k; i++) { + cin >> o >> p; + for (int j = 0; j < 25; j++) + a[o + dx2[j]][p + dy2[j]] = 1; + } + for (int i = 1; i <= n; i++) + for (int j = 1; j <= n; j++) + if (a[i][j] == 0) + ans++; + cout << ans; + return 0; +}