题意:给定n个集合,要求支持4个操作:
1.将集合初始化成{v}
2.令集合Z=集合X∪集合Y
3.令集合
4.查询集合里面v出现的次数并模上2
终于放假了。。好久以前的题。。
答案只需要模2就很容易想到用二进制来表示,那么可以直接上bitset,那么合并相当于做一次模2加,直接异或就行了。。
然后对于操作3,可以直接维护因子出现的个数,维护因子出现次数为g(n),若n在集合中出现f(n)次,那么
然后用
还原
/**
* ┏┓ ┏┓
* ┏┛┗━━━━━━━┛┗━━━┓
* ┃ ┃
* ┃ ━ ┃
* ┃ > < ┃
* ┃ ┃
* ┃... ⌒ ... ┃
* ┃ ┃
* ┗━┓ ┏━┛
* ┃ ┃ Code is far away from bug with the animal protecting
* ┃ ┃ 神兽保佑,代码无bug
* ┃ ┃
* ┃ ┃
* ┃ ┃
* ┃ ┃
* ┃ ┗━━━┓
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━━━━━━━━┳┓┏┛
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛
*/
#include
#include
#include
#include
#include
#include
F. Alex and a TV Show
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Alex decided to try his luck in TV shows. He once went to the quiz named "What's That Word?!". After perfectly answering the questions "How is a pseudonym commonly referred to in the Internet?" ("Um... a nick?"), "After which famous inventor we name the unit of the magnetic field strength?" ("Um... Nikola Tesla?") and "Which rock band performs "How You Remind Me"?" ("Um... Nickelback?"), he decided to apply to a little bit more difficult TV show: "What's in This Multiset?!".
The rules of this TV show are as follows: there are