Prevent swapping two equal items
This commit is contained in:
3
sa.hpp
3
sa.hpp
@@ -65,7 +65,8 @@ class box {
|
||||
auto swappable11(box &other, int capacity) -> bool {
|
||||
long long choice1 = items.top();
|
||||
long long choice2 = other.items.top();
|
||||
return choice1 + other.fullness - choice2 <= capacity &&
|
||||
return choice1 != choice2 &&
|
||||
choice1 + other.fullness - choice2 <= capacity &&
|
||||
choice2 + fullness - choice1 <= capacity;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user