hdu 4858 项目管理(vector模拟)
# include <stdio.h>
# include <algorithm>
# include <string.h>
# include <vector>
# define N 100005
using namespace std;
vector<int>g[N];
int node[N];
int slove(int x)
{
int sum=0,i;
for(i=0;i<g[x].size();i++)
{
sum+=node[g[x][i]];
}
return sum;
}
int main()
{
int t,a,b,c,n,m,q,i;
while(~scanf("%d",&t))
{
while(t--)
{
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++)
{
g[i].clear();
node[i]=0;
}
while(m--)
{
scanf("%d%d",&a,&b);
g[a].push_back(b);
g[b].push_back(a);
}
scanf("%d",&q);
while(q--)
{
scanf("%d",&a);
if(a==0)
{
scanf("%d%d",&b,&c);
node[b]+=c;
}
else
{
scanf("%d",&c);
printf("%d\n",slove(c));
}
}
}
}
return 0;
}
hdu 4858 项目管理(vector模拟)的更多相关文章
- HDU 4858 项目管理(邻接表 暴力模拟)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4858 我们建造了一个大项目!这个项目有n个节点,用很多边连接起来,并且这个项目是连通的! 两个节点间可 ...
- hdu 4858 项目管理 图的分块
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4858 我们建造了一个大项目!这个项目有n个节点,用很多边连接起来,并且这个项目是连通的!两个节点间可能 ...
- HDU 4858 项目管理 分块
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4858 题解: 下面说一个插入查询时间复杂度为sqrt(m)的算法: 对每个点定义两个值:val,su ...
- hdu 4858 项目管理(STL集装箱)
项目管理 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- HDU - 4858 项目管理
N个点,M条无向边.现在有Q组操作,一种是给 i号点增加能量,一种是询问 i号点相邻点的能量和(点间有多条边就算两次). 据说暴力能过,但还是用这题学习了一下 点分块 . 度数不超过 sqrt(M) ...
- hdu 4841 圆桌问题(用vector模拟约瑟夫环)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4841 圆桌问题 Time Limit: 3000/1000 MS (Java/Others) M ...
- uva 101 POJ 1208 The Blocks Problem 木块问题 vector模拟
挺水的模拟题,刚开始题目看错了,poj竟然过了...无奈.uva果断wa了 搞清题目意思后改了一下,过了uva. 题目要求模拟木块移动: 有n(0<n<25)快block,有5种操作: m ...
- UVa 12100 Printer Queue(queue或者vector模拟队列)
The only printer in the computer science students' union is experiencing an extremely heavy workload ...
- 利用C++ STL的vector模拟邻接表的代码
关于vector的介绍请看 https://www.cnblogs.com/zsq1993/p/5929806.html https://zh.cppreference.com/w/cpp/conta ...
随机推荐
- 关于Relay Log无法自动删除的问题
本文介绍了一次运维实践中relay-log长期无法自动删除的原因和解决过程 背景: 今天在运维一个mysql实例时,发现其数据目录下的relay-log 长期没有删除,已经堆积了几十个relay-lo ...
- BNU OJ 1027 金币系统
金币系统 Time Limit: 1000ms Memory Limit: 65535KB 64-bit integer IO format: %lld Java class name: ...
- Leetcode 391.完美矩形
完美矩形 我们有 N 个与坐标轴对齐的矩形, 其中 N > 0, 判断它们是否能精确地覆盖一个矩形区域. 每个矩形用左下角的点和右上角的点的坐标来表示.例如, 一个单位正方形可以表示为 [1,1 ...
- Title共通写法
用: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_c ...
- 开源中国git关联xcode操作步骤
1.网上代码托管有好多我选了开源中国的git 2.开源中国链接:http://git.oschina.net 3.在git上创建一个新的项目 4.打开终端全局设置名字和邮箱 tanqihongdeiM ...
- BZOJ 3907: 网格【组合数学】
Description 某城市的街道呈网格状,左下角坐标为A(0, 0),右上角坐标为B(n, m),其中n >= m.现在从A(0, 0)点出发,只能沿着街道向正右方或者正上方行走,且不能经过 ...
- 【单调队列优化dp】HDU 3401 Trade
http://acm.hdu.edu.cn/showproblem.php?pid=3401 [题意] 知道之后n天的股票买卖价格(api,bpi),以及每天股票买卖数量上限(asi,bsi),问他最 ...
- Spoj-NPC2015A Eefun Guessing Words
Eefun Guessing Words Eefun is currently learning to read. His way of learning is unique, by trying ...
- jenkins异常解答
1.安装插件时offline 需要更换插件管理中的升级URL http://mirror.xmission.com/jenkins/updates/current/update-center.js ...
- 济南学习 Day 5 T1 晚
取模(mod) [题目描述] 有一个整数a和n个整数b_1, …, b_n.在这些数中选出若干个数并重新排列,得到c_1,…, c_r.我们想保证a mod c_1 mod c_2 mod … mod ...