DESCRIPTION:
一开始你有一个空集,集合可以出现重复元素,然后有Q 个操作
1. add s
在集合中加入数字s。
2. del s
在集合中删除数字s。保证s 存在
3. cnt s
查询满足a&s = a 条件的a 的个数
INPUT:
第一行一个整数Q 接下来Q 行,每一行都是3 个操作中的一个
OUTPUT:
对于每个cnt 操作输出答案
SAMPLE INPUT:
7
add 11
cnt 15
add 4
add 0
cnt 6
del 4
cnt 15
SAMPLE OUTPUT:
1
2
2
数据范围:
30%:1<=n<=1000
100%:1<=n<=200000, 0<=s<=2^16

#include<cstdio>
using namespace std;
int main()
{
freopen("subset.in","r",stdin);
freopen("subset.out","w",stdout);
int q(),s(),suffix(),preffix(),cnt();
static int ms[][];
char buf[];
scanf("%d",&q);
while(q)
{
q--;
scanf("%s%d",buf,&s);
switch(buf[])
{
case'a':
preffix=s>>;
s=s&;
for(suffix=s;suffix<=;suffix++)
if((s&suffix)==s)
ms[preffix][suffix]++;
break;
case'c':
suffix=s&;
s=s>>;
cnt=;
for(preffix=s;preffix>=;preffix--)
if((preffix&s)==preffix)
cnt+=ms[preffix][suffix];
printf("%d\n",cnt);
break;
case'd':
preffix=s>>;
s=s&;
for(suffix=s;suffix<=;suffix++)
if((s&suffix)==s)
ms[preffix][suffix]--;
break;
}
}
return ;
}

SUBSET的更多相关文章

  1. [LeetCode] Partition Equal Subset Sum 相同子集和分割

    Given a non-empty array containing only positive integers, find if the array can be partitioned into ...

  2. [LeetCode] Largest Divisible Subset 最大可整除的子集合

    Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of ...

  3. 洛谷 P1466 集合 Subset Sums Label:DP

    题目描述 对于从1到N (1 <= N <= 39) 的连续整数集合,能划分成两个子集合,且保证每个集合的数字和是相等的.举个例子,如果N=3,对于{1,2,3}能划分成两个子集合,每个子 ...

  4. LeetCode "Largest Divisible Subset" !

    Very nice DP problem. The key fact of a mutual-divisible subset: if a new number n, is divisible wit ...

  5. 【USACO 2.2】Subset Sums (DP)

    N (1 <= N <= 39),问有多少种把1到N划分为两个集合的方法使得两个集合的和相等. 如果总和为奇数,那么就是0种划分方案.否则用dp做. dp[i][j]表示前 i 个数划分到 ...

  6. Leetcode 416. Partition Equal Subset Sum

    Given a non-empty array containing only positive integers, find if the array can be partitioned into ...

  7. Leetcode 368. Largest Divisible Subset

    Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of ...

  8. ArcGIS制图之Subset工具点抽稀

    制图工作中,大量密集点显示是最常遇到的问题.其特点是分布可能不均匀.数据点比较密集,容易造成空间上的重叠,影响制图美观.那么,如果美观而详细的显示制图呢? Subset Features(子集要素)工 ...

  9. Largest Divisible Subset

    Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of ...

  10. Subset sum problem

    https://en.wikipedia.org/wiki/Subset_sum_problem In computer science, the subset sum problem is an i ...

随机推荐

  1. docker field

  2. MySQL函数及用法示例

    (一) 1.字符串函数ascii(str)    返回字符串str的第一个字符的ascii值(str是空串时返回0)   mysql> select ascii('2');   -> 50 ...

  3. Git 软件开发过程

    一.关于Git与Subversion的区别 二.目前我们用Subversion是怎么执行软件过程的 三.优势与缺点 架构 * Git:分布式,所有的teammates本地可以clone一份独立完整的仓 ...

  4. YII cookie和session的使用方法

    设置cookie://首先新建cookie$cookie = new CHttpCookie(‘mycookie’, ‘this is my cookie’);//定义cookie的有效期$cooki ...

  5. tensorflow 基本函数(1.tf.split, 2.tf.concat,3.tf.squeeze, 4.tf.less_equal, 5.tf.where, 6.tf.gather, 7.tf.cast, 8.tf.expand_dims, 9.tf.argmax, 10.tf.reshape, 11.tf.stack, 12tf.less, 13.tf.boolean_mask

    1.  tf.split(3, group, input)  # 拆分函数    3 表示的是在第三个维度上, group表示拆分的次数, input 表示输入的值 import tensorflow ...

  6. 光圈、曝光、ISO

    光圈大小对景深的影响: 光圈大小示意图(值越小光圈越大) 光圈.曝光.ISO对图像效果影响

  7. pymysql.err.IntegrityError: (1062, "Duplicate entry 'roxml-ROXML' for key 'PRIMARY'")

    在<Python数据挖掘-概念.方法与实践>一书的第3章实体匹配中,如果一路按照作者的代码及SQL语句进行配置运行的话,会出现如题目所示的错误.根据python脚本的执行错误提示显示,错误 ...

  8. for 续8

    ---------siwuxie095                 一个问题分析: 在 CMD 窗口输入: dir dir /b dir /b /ah dir C:\Windows dir C:\ ...

  9. select_shape_proto算子的几种特征模式含义解析

    select_shape_proto是一个非常有用的region筛选算子,但是由于难以理解,因此一般人使用得不是太多. 算子签名如下: select_shape_proto(Regions, Patt ...

  10. 运行Junit单测时遇到的问题

    现在有两个办法解决: 1.junit版本降到4.10 2.导入hamcrest-core-1.3.jar 官网:JUnit now uses the latest version of Hamcres ...