From 5e1de21a229372553b558feb57426471e265a73e Mon Sep 17 00:00:00 2001 From: Segcolt <9hmbzr275@mozmail.com> Date: Tue, 15 Oct 2024 11:36:59 -0300 Subject: [PATCH] Prevent swapping two equal items --- sa.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sa.hpp b/sa.hpp index 62ccf7e..b5fc1dd 100644 --- a/sa.hpp +++ b/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; }