mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-11-09 16:12:21 +00:00
refactor(P3956.cpp): 移除魔法颜色处理逻辑中的冗余代码
简化bfs函数中处理魔法颜色的代码块,删除未使用的变量和重复逻辑
This commit is contained in:
parent
66ae25f60c
commit
cbde29b00b
@ -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
3
src/10/1/P4162.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
int main(){
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user