4419: [Shoi2013]发微博|暴力|set
2016-03-05 11:10
369 查看
暴力..什么鬼..
一开始以为是LCT后来发现看错题..只有直接的朋友才能看到对方的消息。
对每个人都开一个set维护他的所有朋友,对整个set做一个give的整体标记最后枚举每一个人,再枚举他们的朋友..把标记都暴力传过去
一开始以为是LCT后来发现看错题..只有直接的朋友才能看到对方的消息。
对每个人都开一个set维护他的所有朋友,对整个set做一个give的整体标记最后枚举每一个人,再枚举他们的朋友..把标记都暴力传过去
[code]#include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<vector> #include<cstdio> #include<queue> #include<cmath> #include<set> #include<map> #define N 200005 #define L x<<1 #define R x<<1|1 using namespace std; int sc() { int i=0; char c=getchar(); while(c>'9'||c<'0')c=getchar(); while(c>='0'&&c<='9')i=i*10+c-'0',c=getchar(); return i; } set<int>st ; int get ,give ,n,m; int main() { n=sc(),m=sc(); for(int i=1;i<=m;i++) { char s[5];scanf("%s",s); if(s[0]=='!')give[sc()]++; else if(s[0]=='+') { int x=sc(),y=sc(); get[x]-=give[y]; get[y]-=give[x]; st[x].insert(y); st[y].insert(x); } else { int x=sc(),y=sc(); get[x]+=give[y]; get[y]+=give[x]; st[x].erase(y); st[y].erase(x); } } for(int i=1;i<=n;i++) for(set<int>::iterator it=st[i].begin();it!=st[i].end();it++) get[*it]+=give[i]; for(int i=1;i<=n;i++) { printf("%d",get[i]); if(i!=n)printf(" "); } return 0; }
相关文章推荐
- 限制软件更新的方法和系统
- C# 【String】 用法
- 第13讲——程序阅读题
- ARM-Linux移植之(四)——根文件系统构建
- Linux文件目录及其作用
- LeetCode171:Excel Sheet Column Number
- kaldi-external matrix
- scala使用hbase新api
- leetcode100 Same Tree
- Odoo 8.0深入浅出开发教程(九) Odoo模型层详解
- 程序实现自动生成30道四则运算题目(1)
- 使用Eclipse自带Web Service插件(Axis1.4)生成Web Service服务端/客户端
- scala使用hbase新api
- 【Android】19.0 第19章 前面章节的代码优化及本章示例主界面
- 手机参数篇
- 深入解析CSS中z-index属性对层叠顺序的处理
- LeetCode--328. Odd Even Linked List
- Vulkan -- lonarG SDK安装,
- leetcode283 Move Zeroes
- Odoo 8.0深入浅出开发教程(八) Odoo开发之请假模块第二谈