项目管理 hdoj 4858 (vector初学)
2016-04-29 20:16
399 查看
项目管理 hdoj 4858 (vector初学)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4858
本身是个水水题,但是给刚学的朋友练练手是可以的咯。
题目因为数据太大,会爆内存,用时间换内存就爆了时间。。。
看了下题解,知道用vector,就把vector学了下,水了下面的题。
还不会的同学快来看看吧:
/article/8247661.html
ac代码
注意:用cin,cout会爆时间。。。
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4858
本身是个水水题,但是给刚学的朋友练练手是可以的咯。
题目因为数据太大,会爆内存,用时间换内存就爆了时间。。。
看了下题解,知道用vector,就把vector学了下,水了下面的题。
还不会的同学快来看看吧:
/article/8247661.html
ac代码
注意:用cin,cout会爆时间。。。
#include <stdio.h> #include <math.h> #include <string.h> #include <algorithm> #include <iostream> #include <vector> using namespace std; #define N 100001 #define PI 3.1415927 vector<int> a ; int sum ; int main() { int t; scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); memset(sum,0,sizeof(sum)); int m,n; scanf("%d%d",&n,&m); while(m--) { int x,y; scanf("%d%d",&x,&y); a[x].push_back(y); a[y].push_back(x); } int h; scanf("%d",&h); while(h--) { int pan; cin >> pan; if(pan) { int x,ans=0; scanf("%d",&x); for(int i = 0; i < a[x].size(); i++) ans += sum[a[x][i]]; printf("%d\n",ans); } else { int x,y; scanf("%d%d",&x,&y); sum[x] += y; } } } return 0; }
相关文章推荐
- time_wait状态
- HDU_1245_Saving James Bond_最短路
- iOS播放提示音
- 什么叫内存屏障、编译屏障、内存对齐
- HDU_1245_Saving James Bond_最短路
- RenderTexture 橡皮檫 电筒效果
- 深度优先搜索
- Android录制声音文件(音频),并播放
- android Criteria
- 20145201 实验四 Andoid开发基础
- 1326 - Race
- 【 MVC 】显示数据库数据表格
- Android一句话 | ViewGroup事件分发
- CSS选择器优先级计算
- Reversing Linked List--链表翻转
- iOS 开发中的注意事项
- 飞机最短里程
- pyqt的登录窗口
- 四种强制类型转换的总结(const_cast、static_cast、dynamic_cast、reinterpreter_cast)
- ZJOI2016Day2游记 幻灭