CodeForces-714C

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
", num[bit]);
    }
    return 0;
}


原文地址:https://www.cnblogs.com/cniwoq/p/6770749.html