From cbde29b00ba5b46b1c31e12237a3e01728ea306c Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Wed, 1 Oct 2025 20:49:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor(P3956.cpp):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E9=AD=94=E6=B3=95=E9=A2=9C=E8=89=B2=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=B8=AD=E7=9A=84=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 简化bfs函数中处理魔法颜色的代码块,删除未使用的变量和重复逻辑 --- src/10/1/P3956.cpp | 18 +----------------- src/10/1/P4162.cpp | 3 +++ 2 files changed, 4 insertions(+), 17 deletions(-) create mode 100644 src/10/1/P4162.cpp diff --git a/src/10/1/P3956.cpp b/src/10/1/P3956.cpp index 31124fd..d5569ac 100644 --- a/src/10/1/P3956.cpp +++ b/src/10/1/P3956.cpp @@ -111,23 +111,7 @@ int bfs() { else if (nxtColor == -1 && !used) { int magicCost = 2; for (int magicColor = 0; magicColor <= 1; magicColor++) { - int addCost = 0; - if (lastColor != magicColor) { - addCost = 1; - } - int totalCost = cost + addCost + magicCost; - int newLastColor = magicColor; - bool newused = true; - if (totalCost < dist[nx][ny][newused][newLastColor]) { - dist[nx][ny][newused][newLastColor] = totalCost; - Node nxt; - nxt.x = nx; - nxt.y = ny; - nxt.cost = totalCost; - nxt.lastColor = newLastColor; - nxt.used = newused; - pq.push(nxt); - } + } } } diff --git a/src/10/1/P4162.cpp b/src/10/1/P4162.cpp new file mode 100644 index 0000000..294989d --- /dev/null +++ b/src/10/1/P4162.cpp @@ -0,0 +1,3 @@ +int main(){ + +} \ No newline at end of file