Codeforces-713A Sonya and Queries
来源:互联网 发布:淘宝理财官网 编辑:程序博客网 时间:2024/04/28 18:38
题目大意:
+ x表示向一个mutiset里增加一个数x
- x表示向一个mutiset里面减少一个数x
? x表示询问这个mutiset里面能够与x匹配的数的个数,匹配规则是x只由01组成,0表示偶数,1表示奇数。当x比要匹配的数长度短的时候,在x前面补0,当x比要匹配的数长度长的时候,在待匹配的数前面补0
解题思路:
乍一看觉得应该用字典树写。其实不然。
直接设一个长度为2^18的数组a,a[i]的意思是,能与状态i匹配的数字的个数。
代码:
#include <map>#include <set>#include <queue>#include <stack>#include <cstdio>#include <string>#include <vector>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#include <functional>using namespace std;#define mp make_pair#define pb push_back#define lson (rt << 1)#define rson (rt << 1 | 1)typedef long long LL;typedef pair<int, int> pi;const int maxn = (1 << 18) + 10;int cas;int st[maxn];int main() {ios::sync_with_stdio(false); cin.tie(0);cin >> cas;while (cas--) {char op; LL num, tmp, los = 0;cin >> op >> num;int status = 0;while (num) {tmp = num % 10;num /= 10;if (tmp & 1) status |= (1 << los);++los;}//cout << status << endl;if (op == '+') st[status] += 1;else if (op == '-') st[status] -= 1;else cout << st[status] << endl;}//system("pause");return 0;}</span>
0 0
- codeforces 713 A. Sonya and Queries
- Codeforces-713A Sonya and Queries
- Codeforces Problem 713A Sonya and Queries(字典树)
- CodeForces 713A|Sonya and Queries|字典树|没方法
- A. Sonya and Queries
- Codeforces Round #371 (Div. 1)A Sonya and Queries
- codeforces-371-C. Sonya and Queries
- Codeforces 371C - Sonya and Queries(思维)
- CodeForces-714C - Sonya and Queries【状压 】
- Codeforces Round #371 (Div. 1) A. Sonya and Queries(trie)
- Codeforces Round #371 (Div. 1)-A. Sonya and Queries(Trie树)
- [CF713A]Sonya and Queries
- 【DP】[CodeForces - 713C]Sonya and Problem Wihtout a Legend
- Codeforces-713C Sonya and Problem Wihtout a Legend
- codeforces 713C Sonya and Problem Wihtout a Legend【dp】
- Codeforces #713C: Sonya and Problem without a Legend 题解
- Codeforces-713C-Sonya and Problem Wihtout a Legend
- Codeforces Round #371 (Div. 2) C. Sonya and Queries
- PAT(A) - 1087. All Roads Lead to Rome (30)
- 开始博客之旅
- leetcode小白解题记录——第十一题
- bzoj 1076: [SCOI2008]奖励关 期望dp+状态压缩
- zookeeper学习心得
- Codeforces-713A Sonya and Queries
- jsp页面引入css文件报错 javax.servlet cannot be resolved to a type
- 【数据结构】算法6.5-6.7 线索二叉树
- [LeetCode]--202. Happy Number
- 知识点一:序列
- java技术支持-图书馆
- aws 恢复mysql数据库数据
- Linux系统下如何查看及修改文件读写权限
- 静态页面制作(三)