本文共 882 字,大约阅读时间需要 2 分钟。
不用字典树进行维护,直接状压用数组保存就可以了。
#include #include #include #include #include #include #include #include #include #include #include #include #include //#include //#define LOACL#define space " "using namespace std;typedef long long LL;//typedef __int64 Int;typedef pair 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;}
转载于:https://www.cnblogs.com/cniwoq/p/6770749.html