NBUT 1554 Lord of Minecraft
来源:互联网 发布:apache mime类型 json 编辑:程序博客网 时间:2024/03/29 23:52
请不要随便指点别人该怎么做、每个人的人生都应该自己掌握、你给不了别人一切、你也不懂别人的忧伤、
微笑不代表快乐、哭泣不一定悲伤
不努力怎么让关心你的人幸福、不努力怎么让看不起你的人绝望、
我用生命在奋斗——lx_Zz
—————————————————————————————————————————————————————————————
————————————————————————— 华丽的分割线 ————————————————————————————
—————————————————————————————————————————————————————————————
140448DreamofFinal70312161443G++2014-05-09 11:26:07我要被自己恶心死了、、、怎么写都不对、上次直接BFS因为数据加强被挂掉了、然后重新写、一写几个小时、
一定是因为昨晚睡太晚了、所以怎么写都不对、、好蛋疼、
# include <cstdio># include <cstring># include <string># include <map># include <vector>using namespace std;const int maxn = 10005;int n, m;map <string, int> mp;vector <int> G[maxn];int d[maxn];int l[maxn], r[maxn];int id, root;char sx[15], sy[15];int cnt;int head[maxn];struct node{int to,next;}edge[maxn];int k;void add(int x,int y){edge[k].to=y;edge[k].next=head[x];head[x]=k++;}void dfs(int cur, int depth){ d[cur] = depth; l[cur] = cnt++; for(int i=head[cur];i!=-1;i=edge[i].next)dfs(edge[i].to,depth+1); r[cur] = cnt++;}int add(const string &s){ return mp[s]>0 ? mp[s]:(mp[s]=++id);}void init(void){k=0;memset(head,-1,sizeof(head)); id = 0; mp.clear(); for (int i = 1; i <= n+1; ++i) G[i].clear(); for (int i = 0; i < n; ++i) { scanf("%s%s", sx, sy); int x = add(sx), y = add(sy); if (strcmp(sy, "Hungar") == 0) root = y; add(y,x); } cnt = 0; dfs(root, 0);}void solve(void){ int ans = 0; for (int i = 0; i < m; ++i) { scanf("%s%s", sx, sy); stx = sx, sty = sy; int x = mp[stx]; int y = mp[sty]; if ((d[x]<d[y] && !(l[x]<l[y] && r[y]<r[x])) || (d[x]==d[y])) ++ans; } printf("%d\n", ans);}int main(){ while (EOF != scanf("%d%d", &n, &m)) { init(); solve(); } return 0;}
- NBUT 1554 Lord of Minecraft
- NBUT 1554 Lord of Minecraft
- [noj 1554] Lord of Minecraft
- NBUT Minecraft Server Bug
- NBUT 1552 Minecraft Server Bug
- NBUT 2014 校赛 (Minecraft专场)
- The Lord Of The Rings
- 今天看了the lord of king
- 搜索 HOJ 1226 Lord of the Ring
- Meaning Of Names In The Lord Of The Ring
- NBUT 1557 Team of Slime
- Minecraft
- Minecraft
- NBUT
- NBUT
- NBUT
- NBUT
- NBUT
- Android Layout Binder(在线将XML中View find出来,生成java代码的工具)
- NoSQL数据库探讨之一 - 为什么要用非关系数据库?
- linux 环境编程之 map,munmap 内存映射文件
- 前台json数组传到后台解析
- HDOJ1033 Edge
- NBUT 1554 Lord of Minecraft
- 如何看懂ORACLE执行计划
- svn如何恢复误删除的数据
- 读取一个大文件的高效的方法
- 计算机网络-自顶向下方法和Internet特色笔记之三(中)
- Essential WinForm用户界面控件包User Interface Edition for Windows Forms 下载及介绍
- android垃圾回收机制及程序优化System.gc
- 读配置文件
- 《简单计算器实现(c#)》