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 ...
随机推荐
- TortoiseGit 常见问题汇总
1.test分支修改后合并到master分支 1)切换本地分支到master分支 2)TortoiseGit ---> merge,选择远程分支test 提交到远程分支master 2.将远程 ...
- 使用C#做为游戏开发的服务器语言方案
Scut开源服务器 开源C#/Python/Lua 手游服务器 主页:http://www.scutgame.com/index.html 开源:https://github.com/ScutGame ...
- 文档级关系抽取:基于结构先验产生注意力偏差SSAN模型
文档级关系抽取:基于结构先验产生注意力偏差SSAN模型 Entity Structure Within and Throughout: Modeling Mention Dependencies fo ...
- 【一】MADDPG-单智能体|多智能体总结(理论、算法)
相关文章: [一]MADDPG-单智能体|多智能体总结(理论.算法) [二]MADDPG--单智能体|多智能体总结算法实现--[追逐游戏] [一]-环境配置+python入门教学 [二]-Parl基础 ...
- 10.2 调试事件获取DLL装载
理解了如何通过调试事件输出当前进程中寄存器信息,那么实现加载DLL模块也会变得很容易实现,加载DLL模块主要使用LOAD_DLL_DEBUG_EVENT这个通知事件,该事件可检测进程加载的模块信息,一 ...
- Tomcat8安装手记
Tomcat安装虽然简单,稍不注意,就会坠入万丈深渊,记录痛苦的安装经历. 首先先介绍一下安装条件和正确的安装方式. 安装条件 系统已经安装jdk(前提) tomcat8压缩包 (可以去官网下载 或者 ...
- 利用Docker、云服务器、mongodb搭建自己的测试平台
准备一个云服务器 购买一个云服务器,在阿里云,腾讯云上购买即可. 然后创建一个实例,安装Linux操作系统,我安装的是CentOS. 记住账号和密码,可以使用ssh远程登录即可. 搭建测试环境 D ...
- Windows 7 Ultimate with Service Pack 1 (x64)
Windows 7 Ultimate with Service Pack 1 (x64) 链接:https://pan.baidu.com/s/1ZHODDFlJPLQ3ydxZ4rfc3g 提取码: ...
- PHP中GD库
PHP中GD库 一.GD库的介绍 1.GD库是什么? Graphic Device,图像工具库,gd库是php处理图形的扩展库,GD库提供了一系列用来处理图片的API,使用GD库可以处理图片,或者生成 ...
- P9247 [集训队互测 2018] 完美的队列题解
题目链接:[集训队互测 2018] 完美的队列 神仙数据结构题,看了很多题解才搞懂.在做此题之前,最好对分块很熟悉,对各类标记非常熟练.考虑题意说的种类是相对于全局的.我们可以考虑局部影响对全局影响. ...