Educational Codeforces Round 65 (Rated for Div. 2)C. News Distribution(模拟,计算的时候去重)
这道题目明显和出现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(模拟,计算的时候去重)的更多相关文章
- 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 ...
- Educational Codeforces Round 65 (Rated for Div. 2)题解
Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- [ 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 ...
- Educational Codeforces Round 65 (Rated for Div. 2)
A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 ...
- Educational Codeforces Round 65 (Rated for Div. 2) E. Range Deleting(思维+coding)
传送门 参考资料: [1]:https://blog.csdn.net/weixin_43262291/article/details/90271693 题意: 给你一个包含 n 个数的序列 a,并且 ...
- 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 ...
随机推荐
- js设计模式(下)
引用:(23条消息) <Javascript设计模式与开发实践>关于设计模式典型代码的整理(下):模板方法模式.享元模式.职责链模式.中介者模式.装饰模式.状态模式.适配器模式_QQsil ...
- hadoop实践02---eclipse操作hdfs的api上传文件
1.eclipse中编写代码后双击main方法--->Run as ---> java application ,然后指定的文件 就会提交到hdfs中. 2.查看文件:http://192 ...
- 根据pdf模板文件添加数据生成新的pdf与pdf添加读取二维码
参考文档 :https://www.cnblogs.com/ibeisha/p/itextsharp-pdf.html 程序demo 地址:https://github.com/hudean/itex ...
- 【3】超级详细matplotlib使用教程,手把手教你画图!(多个图、刻度、标签、图例等)
相关文章: 全网最详细超长python学习笔记.14章节知识点很全面十分详细,快速入门,只用看这一篇你就学会了! [1]windows系统如何安装后缀是whl的python库 [2]超级详细Pytho ...
- 4.6 C++ Boost 函数绑定回调库
Boost 库是一个由C/C++语言的开发者创建并更新维护的开源类库,其提供了许多功能强大的程序库和工具,用于开发高质量.可移植.高效的C应用程序.Boost库可以作为标准C库的后备,通常被称为准标准 ...
- 给textarea添加行号,textarea使用代码风格的一些思考
背景 项目有个需求是 在textarea中编辑脚本并显示为代码风格样式,显示行号: textarea显示行号 思路: 1.监听textarea内容变化,执行一个change函数,解析内容里面有多少个换 ...
- Nexus系列:简介和安装(Windows、Linux)以及反向代理Nexus
目录 简介 安装 Windows Linux Nexus相关命令 Nginx反向代理Nexus 简介 Sonatype Nexus是一个Maven仓库管理器,可以节省网络带宽并加速项目搭建的进程.它可 ...
- Linux 进程卡住了怎么办?
在我们使用 Linux 系统时,如果网络或者磁盘等 I/O 出问题,会发现进程卡住了,即使用 kill -9 也无法杀掉进程,很多常用的调试工具,比如 strace, pstack 等也都失灵了,是怎 ...
- SQLWorkbench使用自定义JDBC驱动连接数据库
一.Windows上使用SQLWorkbench 1. 添加CloudDB的驱动,点击"Manage Driver". Name : Fandatsys-CDB sample U ...
- python-比较两个列表中的相同元素和不同元素
由于两个列表(List)中可能会存在重复的元素,所以我们可以将列表转化成集合(set)进行去重,然后计算交集和差集. A = ['1','2','3'] B = ['2','4','5'] ##计算交 ...