At their first crossing A has swum 30 and B has swum x - 30 , where x is the pool length.
At their second crossing A has now swum x + 20 in all and B has swum 2x - 20
There respective distances will keep in a fixed ratio because their speeds are in a fixed ratio.
This equation expresses that
x is zero or 70, and a pool of length zero is not our interest here so 70 m is the pool's length.
Here's another line of reasoning :
At first crossing A and B have swum one length between them, and A swam 30m of that length.
At second crossing A and B have swum two more lengths between them, so A will have swum 60m of those two lengths.
A has swum 90m in all, and that is one whole length plus a further 20m . So the pool is 70m long.