I will focus on what you point out as your actual core problem, how to keep track of objects you used in one bag, the other bag or not at all.
Make a list (array, vector, ... whatever container you prefer) and note for each of the objects where you used it - or not.
index |
value |
meaning |
0 |
0 |
not used |
1 |
0 |
not used |
2 |
0 |
not used |
3 |
1 |
used in one bag |
4 |
2 |
used in other bag |
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…