From the RAG, we can see that only 1(r3) is free. P0 and P2 are contesting for 1(r3).
Now we have 0(r1) and 0(r2) and 1(r3) available.
If we give 1(r3) to P0, it will be still waiting for 1(r2).
If we give 1(r3) to P2, it will execute and release 1(r2) and 1(r3).
P2 needs 1(r3), so it will execute and release 1(r2) additionally.
Now we have 0(r1) and 1(r2) and 1(r3) available.
P0 needs 1(r2) and 1(r3), so it will execute and release 1(r3) and 1(r1) additionally.
Now we have 1(r1) and 1(r2) and 2(r3) available.
No one wants any instance of r3.
P1 needs 1(r1), so it will execute and release 1(r1) and 1(r2) additionally.
Now we have 2(r1) and 2(r2) and 2(r3) available.
P3 needs 1(r1) and 2(r2), so it will execute and release 1(r2) additionally.
Now we have 2(r1) and 3(r2) and 2(r3) available.
As long as I am able to find a way to execute all the processes in some order without being stuck, I can say my system is in safe state, and there exists a safe sequence [for example P2=>P0=>P1=>P3 in this case]