这道题目明显和出现4次的数和出现2次的数的个数有关系,只需要在每次更新之后维护这两个信息即可,我们在算出现2次的数的个数时其实会把出现4次的数的个数会把出现2次的数的个数+2,在判断时需要考虑这一点。也就是\(cnt2>=4\&\&cnt4>=1\)时才有解

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
#define x first
#define y second
using namespace std; const int N=1e5+10,mod=1e9+7;
int a[N],cnt[N]; void solve()
{
int n,f=0,t=0;
cin>>n;
rep(i,1,n)
{
cin>>a[i];
cnt[a[i]]++;
if(cnt[a[i]]%4==0) f++;
if(cnt[a[i]]%2==0) t++;
}
int q;cin>>q;
while(q--)
{
char op;int k;cin>>op>>k;
if(op=='+')
{
cnt[k]++;
if(cnt[k]%4==0) f++;
if(cnt[k]%2==0) t++;
}
if(op=='-')
{
if(cnt[k]%4==0) f--;
if(cnt[k]%2==0) t--;
cnt[k]--;
}
if(f>=1&&t>=4) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
} int main()
{
IOS
// freopen("1.in", "r", stdin);
int t;
// cin>>t;
// while(t--)
solve();
return 0;
}

Educational Codeforces Round 65 (Rated for Div. 2)C. News Distribution(模拟,计算的时候去重)的更多相关文章

  1. Educational Codeforces Round 65 (Rated for Div. 2) C. News Distribution

    链接:https://codeforces.com/contest/1167/problem/C 题意: In some social network, there are nn users comm ...

  2. Educational Codeforces Round 65 (Rated for Div. 2)题解

    Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...

  3. Educational Codeforces Round 65 (Rated for Div. 2) D. Bicolored RBS

    链接:https://codeforces.com/contest/1167/problem/D 题意: A string is called bracket sequence if it does ...

  4. Educational Codeforces Round 65 (Rated for Div. 2) B. Lost Numbers

    链接:https://codeforces.com/contest/1167/problem/B 题意: This is an interactive problem. Remember to flu ...

  5. Educational Codeforces Round 65 (Rated for Div. 2) A. Telephone Number

    链接:https://codeforces.com/contest/1167/problem/A 题意: A telephone number is a sequence of exactly 11  ...

  6. Educational Codeforces Round 65 (Rated for Div. 2)B. Lost Numbers(交互)

    This is an interactive problem. Remember to flush your output while communicating with the testing p ...

  7. [ Educational Codeforces Round 65 (Rated for Div. 2)][二分]

    https://codeforc.es/contest/1167/problem/E E. Range Deleting time limit per test 2 seconds memory li ...

  8. Educational Codeforces Round 65 (Rated for Div. 2)

    A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 ...

  9. Educational Codeforces Round 65 (Rated for Div. 2) E. Range Deleting(思维+coding)

    传送门 参考资料: [1]:https://blog.csdn.net/weixin_43262291/article/details/90271693 题意: 给你一个包含 n 个数的序列 a,并且 ...

  10. Educational Codeforces Round 65 (Rated for Div. 2)(ACD)B是交互题,不怎么会

    A. Telephone Number A telephone number is a sequence of exactly 11 digits, where the first digit is  ...

随机推荐

  1. easyUI 多表头设置

  2. DotLiquid(.net模版引擎)

    可用生成C#代码,在KSFramework中有使用:https://github.com/mr-kelly/KSFramework 主页:http://dotliquidmarkup.org/ 文档: ...

  3. PE格式:新建节并插入DLL

    首先老样子,我们先来到PE节表位置处,并仿写一个.hack的节,该节大小为0x1000字节,在仿写前我们需要先来计算出.hack的虚拟偏移与实际偏移,先来查询一下当前节表结构,如下: 接着我们通过公式 ...

  4. 46从零开始用Rust编写nginx,数据还能这么传,多层代理(IP多级代理)搭建

    wmproxy wmproxy已用Rust实现http/https代理, socks5代理, 反向代理, 负载均衡, 静态文件服务器,websocket代理,四层TCP/UDP转发,内网穿透等,会将实 ...

  5. 解决github无法进入问题,DNS加速

    1.电脑的hosts文件在下面这个地址,找到hosts文件 C:\Windows\System32\Drivers\etc 2.进入文件夹目录etc 找到hosts文件,使用记事本编辑 3.进入这个网 ...

  6. 【C语言深度解剖】一篇搞懂结构体内存对齐【结构体的大小你会算了吗】

    结构体内存对齐 大家好,我是西城s 文章目录 前言 引入 结构体内存对齐 `offsetof`宏的使用 为什么存在结构体内存对齐 修改默认对齐数 尾声 前言 作者: #西城s 这是我的主页:#西城s ...

  7. 使用C语言构建一个独立栈协程和共享栈协程的任务调度系统

    使用了标准库头文件 <setjmp.h>中的 setjmp 和 longjmp两个函数,构建了一个简单的查询式协作多任务系统,支持独立栈和共享栈两种任务. 其中涉及到获取和设置栈的地址操作 ...

  8. python-命令行参数处理 getopt模块详解

    背景 在写脚本程序的时候需要添加一些额外的参数来实现脚本的附加功能或者增强功能,通常的做法是通过sys.argv[i]直接来获取参数的值,但是这个比较局限,要求参数的输入一定要按照顺序. fileNa ...

  9. Asp .Net Core 系列:Asp .Net Core 集成 Panda.DynamicWebApi

    目录 简介 Asp .Net Core 集成 Panda.DynamicWebApi 配置 原理 什么是POCO Controller? POCO控制器原理 ControllerFeatureProv ...

  10. C语言程序设计之字符串处理

    C语言程序设计-字符串处理 第一题:回文数判断 问题描述] 回文是正读和倒读都一样的句子.读入一个最大长度不超过50个字符的句子,判断其是否是回文. [输入形式] 输入一个最大长度不超过50个字符的句 ...