That would work for the original question, but with the delayed death and quick response conditions imposed by pooriaazimi[0], it would not work. Tying the solution back to binary, you realize that each barrel has a unique 10-bit identifier (2^10=1024, so numbering the barrels in binary gives each one a unique ID). You assign each prisoner to a bit, then have them all drink from the barrels where their bit is a 1. 30 days later, you'll have a pattern of prisoner deaths exactly matching a single barrel.
Note: I have not verified this solution, and it does not match the solution that was posted elsewhere in this thread.
Note: I have not verified this solution, and it does not match the solution that was posted elsewhere in this thread.
[0] https://news.ycombinator.com/item?id=3804350