CodeForces-714C - Sonya and Queries【状压 】

 

C - Sonya and Queries

CodeForces - 714C 

 

不用字典树进行维护,直接状压用数组保存就可以了。

 

#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <queue>
#include <iostream>
#include <stack>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
//#include <bits/stdc++.h>
//#define LOACL
#define space " "
using namespace std;
typedef long long LL;
//typedef __int64 Int;
typedef pair<int, int> paii;
const int INF = 0x3f3f3f3f;
const double ESP = 1e-5;
const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const int MAXN = 100000 + 10;
LL num[1 << 19], a;
int main() {
    int T;
    char op;
    memset(num, 0, sizeof(num));
    scanf("%d", &T);
    while (T--) {
        getchar();
        scanf("%c%lld", &op, &a);
        LL bit = 0;
        for (int i = 0; i < 18; i++) {
             bit |= ((a % 10) & 1) << i, a /= 10;
        }
        if (op == '+') num[bit]++;
        else if (op == '-') num[bit]--;
        else printf("%d\n", num[bit]);
    }
    return 0;
}

 


 

posted @ 2016-12-06 21:01  zprhhs  阅读(159)  评论(0编辑  收藏  举报
Power by awescnb