refactor(P3956.cpp): 移除魔法颜色处理逻辑中的冗余代码

简化bfs函数中处理魔法颜色的代码块,删除未使用的变量和重复逻辑
This commit is contained in:
Zengtudor 2025-10-01 20:49:03 +08:00
parent 66ae25f60c
commit cbde29b00b
2 changed files with 4 additions and 17 deletions

View File

@ -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);
}
}
}
}

3
src/10/1/P4162.cpp Normal file
View File

@ -0,0 +1,3 @@
int main(){
}