Sonya and Queries CodeForces - 714C (map映射)

什么是以太网链路聚合 以太网链路聚合技术通过将多个物理端口捆绑成逻辑端口,可显著提升网络性能。该技术能增加总带宽(各链路带宽之和)、提高可靠性(故障秒级切换)并实现智能负载分担。主要分为手工模式和基于LACP协议的动态模式,后者能检测链路故障更可靠。配置时需确保接口参数一致、模式匹配,适用于核心交换、服务器接入等场景。华为设备通过创建Eth-Trunk接口、指定LACP模式并添加成员接口即可完成部署。这项成熟技术能以低成本解决带宽瓶颈和可靠性问题,是构建高速稳定网络的关键方案。 阅读详情

Sonya and Queries

CodeForces - 714C

Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type:

  1.  +  ai — add non-negative integer ai to the multiset. Note, that she has a multiset, thus there may be many occurrences of the same integer.
  2.  -  ai — delete a single occurrence of non-negative integer ai from the multiset. It's guaranteed, that there is at least one ai in the multiset.
  3. ? s — count the number of integers in the multiset (with repetitions) that match some pattern s consisting of 0 and 1. In the pattern, 0 stands for the even digits, while 1 stands for the odd. Integer x matches the pattern s, if the parity of the i-th from the right digit in decimal notation matches the i-th from the right digit of the pattern. If the pattern is shorter than this integer, it's supplemented with 0-s from the left. Similarly, if the integer is shorter than the pattern its decimal notation is supplemented with the 0-s from the left.

For example, if the pattern is s = 010, than integers 92, 2212, 50 and 414 match the pattern, while integers 3, 110, 25 and 1030 do not.

Input

The first line of the input contains an integer t (1 ≤ t ≤ 100 000) — the number of operation Sonya has to perform.

Next t lines provide the descriptions of the queries in order they appear in the input file. The i-th row starts with a character ci — the type of the corresponding operation. If ci is equal to '+' or '-' then it's followed by a space and an integer ai (0 ≤ ai < 1018) given without leading zeroes (unless it's 0). If ci equals '?' then it's followed by a space and a sequence of zeroes and onse, giving the pattern of length no more than 18.

It's guaranteed that there will be at least one query of type '?'.

It's guaranteed that any time some integer is removed from the multiset, there will be at least one occurrence of this integer in it.

Output

For each query of the third type print the number of integers matching the given pattern. Each integer is counted as many times, as it appears in the multiset at this moment of time.

Example
Input
12
+ 1
+ 241
? 1
+ 361
- 241
? 0101
+ 101
? 101
- 101
? 101
+ 4000
? 0
Output
2
1
2
1
1
Input
4
+ 200
+ 200
- 200
? 0
Output
1
Note

Consider the integers matching the patterns from the queries of the third type. Queries are numbered in the order they appear in the input.

  1. 1 and 241.
  2. 361.
  3. 101 and 361.
  4. 361.
  5. 4000.

这个题仔细观察会发现这要数字符合01的某种模式其实每个数字没有区别,因为最后我们输出的仅仅就是符合某种01模式的数的个数,所以我们把所有数都转换成01模式,用map映射,记录每种的个数就可以了,然后输出

code:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
map<ll,int>b;
int main(){
    int t,i;
    scanf("%d",&t);
    char op;
    ll num;
    for(i = 0; i < t; i++){
        getchar();
        scanf("%c %lld",&op,&num);
        int x = 0,bit = 0;
        while(num){
            if(num%10%2)
                x |= (1<<bit);//转化成奇偶10模式
            num /= 10;
            bit++;
        }
        if(op == '+')
            b[x]++;
        if(op == '-')
            b[x]--;
        if(op == '?')
            printf("%d\n",b[x]);
    }
    return 0;
}


nRF52382低功耗蓝牙应用开发之入门教程-软件烧录 准备工作在上一篇文章讲过了,这里就讲讲nRFgo studio的使用 硬件准备: J-link:2线 供电:3.3V 如下图打开nRFgo studio界面介绍, 2、如果J-link正常,如下图 3、如果蓝牙芯片正常 4、烧录过程,如果蓝牙芯片之前有烧录过程序,需先点擦除,再点烧录 5、烧录代码路劲,例如 F:\nRF\SDK\nRF5_SDK_15.2.0_... 阅读详情

相关推荐

从SAS接口到InfiniBand:一张图看懂数据中心硬件‘黑话’(SFF-8643/8644、QSFP112、NDR/HDR/EDR)

本文深入解析数据中心硬件术语,从SAS接口标准(SFF-8643/8644)到速率标识(NDR/HDR/EDR),帮助工程师快速理解关键性能指标。特别对比了PCIe卡规格(HHHL/FHHL)和光模块选择(QSFP112/OSFP),并探讨InfiniBand在高性能网络中的优势,为硬件选型提供实用指南。

weixin_32103009的博客 425

Codeforces Round #371 (Div. 1) A. Sonya and Queries(trie)

A. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers and invit

WZJRJ28 434

基于Python的信用卡欺诈检测机器学习案例报告

当今时代,在线支付已成为一种高效便捷的支付方式,我们可以突破时间和空间的限制,输入我们的信用卡各项信息就可以完成在线支付。但随之而来的是这种支付方式也具备一定的风险性,我们无法辨别对方是否是恶意套取我们资金的非法分子。当信用卡信息数据泄露导致金钱失窃并最终失去客户忠诚度和公司声誉时,组织、消费者、银行和商家都会面临风险。2017 年,未经授权的信用卡操作达到了惊人的 1670 万受害者。此外,据美国联邦贸易委员会 (FTC) 报告,2017 年信用卡欺诈索赔数量比上一年高出 40%。

weixin_45673389的博客 6689

Codeforces Round #371 (Div. 2)C. Sonya and Queries【字典树】

C. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers

走一步再走一步 764

数据驱动的细胞动力学:从高通量成像到机器学习预测的完整实践指南

细胞动力学研究细胞群体随时间变化的规律和命运决策机制,是理解生命过程的基础。其核心原理在于将传统的定性观察转化为定量分析,通过高通量成像、单细胞测序等技术获取多维时序数据,并运用机器学习与统计模型挖掘数据中的深层模式。这一技术价值在于实现从“描述现象”到“预测行为”的范式转变,显著提升研究的客观性和可重复性。在应用场景上,它广泛应用于药物筛选、疾病机制研究和发育生物学等领域,能够加速靶点发现和疗效评估。本文聚焦于数据驱动的细胞动力学分析,详细拆解了从实验设计、图像处理、单细胞追踪到特征工程与建模预测的端到端

weixin_29056781的博客 267

PowerBuilder 9.0安装组件全解析:Adaptive Server Anywhere、PowerDynamo、InfoMaker到底怎么选?

本文从技术架构师视角详细解析PowerBuilder 9.0安装组件选型策略,包括Adaptive Server Anywhere、PowerDynamo和InfoMaker的核心功能与应用场景。通过分析组件间的依赖关系和安装冲突机制,提供针对不同开发需求的最佳安装方案,帮助开发者高效配置PB9.0开发环境。

weixin_28700593的博客 440

CodeForces 713A|Sonya and Queries|字典树|没方法

给出一些数字,询问一些满足对应位为偶数(0表示)或奇数(1表示)的数字的个数。 比如010格式的数字可以有818,52,98,2212等。首先各位数具体为多少并没有什么关系,所以全都模2,将长度扩展到18方便位数不相等的查询。 然后扔到字典树里查询就好啦。#include <cstdio> #include <cstring> #include <algorithm> using namespa

とある黄鱼のOIブログ 764

2023华为od机试【最小循环子数组】C++

2023华为od机试【最小循环子数组】C++ 给定一个由若干整数组成的数组nums,请检查数组是否是由某个子数组重复循环拼接而成,请输出这个最小的子数组。

MISAYAONE的博客 2185

codeforces 714C Sonya and Queries [思维]【STL】

题目链接:http://codeforces.com/contest/714/problem/C————————————-. C. Sonya and Queries time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Today

Tabris的博客 993

STM32CubeMX之emWin移植

“前面两章介绍了SDRAM和LTDC的使用,本篇文章将介绍emWin移植到STM32。”硬件环境:STM32F429IGT6软件环境:STM32CubeMX v5.5.0...

zhang062061的专栏 2826

cesium 实现经纬线绘制和经纬度标注

废话不对数直接上线效果图及代码 1.效果图 2.实现代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=

一碗老面的博客 2569

Codeforces_713_A

http://codeforces.com/problemset/problem/713/A 将读入的数全都存为二进制,用map保存对应的个数。 #include<iostream> #include<cstring> #include<cstdio> #include<map> #define LL __int...

diaotan0836的博客 195

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

http://codeforces.com/problemset/problem/714/C Sonya and Queries

Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers an

nankeyimeng的博客 781

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

C. Sonya and Queries

http://codeforces.com/contest/714/problem/C 看到这题目,想想,肯定不能暴力啊,如果用map,如何快速找到满足要求的数目,然后,长度18,我想,这不是熟悉的trie树么,还犹豫什么,把所有的输入都处理成长度为18的字符串,处理就行了,然后调试了一会,就交了,然后tle了,我就怀疑了,难道不是这样的套路么?!然后就开始查答案,一看官方题解,恍然大...

weixin_30449453的博客 115

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Codeforces #371(Div.2)C.Sonya and Queries【思维+map应用】

C. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers and invit

mengxiang000000 900

[CF713A]Sonya and Queries

Codeforces 数据结构

YveH 701

codeforces 713A Sonya and Queries (状态压缩)

点击查看原题:http://codeforces.com/problemset/problem/713/A 题目分析 题意:我们有三种操作: 1)+ a,向集合中添加一个数a 2)- a ,减去集合中的一个数,保证a一定存在于集合中 3)? s , s仅有‘0’和‘1’组成,‘0’所在位置表示这个位置的数需要为偶数,‘1’所在位置表示这个位置的数需要为奇数,用s去和集合中所有的数...

天际苍穹的博客 228

A. Sonya and Queries

题目大意,就是给你几种操作,添加, 删除,查询裸的字典树题目.. #include <algorithm> #include <stack> #include <istream> #include <stdio.h> #include <map> #include <math.h>...

axian1654的博客 224

Codeforces-713A Sonya and Queries

题目大意: + x表示向一个mutiset里增加一个数x - x表示向一个mutiset里面减少一个数x ? x表示询问这个mutiset里面能够与x匹配的数的个数,匹配规则是x只由01组成,0表示偶数,1表示奇数。当x比要匹配的数长度短的时候,在x前面补0,当x比要匹配的数长度长的时候,在待匹配的数前面补0 解题思路: 乍一看觉得应该用字典树写。其实不然。 直接设一个长度为2^18的

Wilbert的博客 638

Codeforces Round #371 (Div. 2)C. Sonya and Queries

C. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers

K键盘里的青春K 944

Codeforces Round #371 (Div. 2) C. Sonya and Queries (01trie树)

分析:一看奇偶相互间隔,01trie树直接上,然后调试了整场…….最后Xcode单步调试才查出一个语句顺序错误,还是思维模型不真实。调试好之后只有30s提交wa5,然后发现数据是long long急忙改,还是没来得及,赛后把改了long long的交了就过了。。。 还有本场终于上紫色了JIBANCANYANGJIBANCANYANG 其实可以直接丢数组,因为2182^{18}种不多。。。。

JIBANCANYANG 469

Codeforces #371(Div.2)C.Sonya and Queries【map应用】【思维】

传送门 :C. Sonya and Queries 描述: C. Sonya and Queries time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Tod

魔笛手的博客 966

Codeforces 714 C. Sonya and Queries (思维)

Description Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of th...

小坏蛋_千千 624

CodeForces 714C Sonya and Queries(字典树/思维)

Description Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the f...

so_so_y的博客 279

C - Sonya and Queries

Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type: +  ai — add non-negative integer ai to the multiset. N

Hello_wcrd的博客 312

Sonya and Queries CodeForces - 714C 字典树

Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her tqueries, each of one of the following type:...

mayuqing98的博客 338
上一篇: Filya and Homework CodeForces - 714B
下一篇: Revolving Digits HDU - 4333 (扩展kmp)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值