G - Takoyaki and Flip 解説 by RDFZchenyy

You can avoid segment tree tags

The thing is we need to find out which plate is placed face-up, and which is placed face-down.

So we can use two fhq-Treap to do this, to achieve this, just maintain two tags - set numbers to zero and add a number. The first fhq-treap contains the plate placed face-up, the other contains the plate placed face-down. When we want to flip, just split and swap the subtree.

Submission

投稿日時:
最終更新: