Currency Exchange Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 19881   Accepted: 7114 Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and pe…
Silver Cow Party Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 12674   Accepted: 5651 Description One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X …
1218: 奇奇与变形金刚 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 130  Solved: 37[Submit][Status][Web Board] Description 奇奇 gigi     奇奇口头禅:别人的失败就是我的快乐! 星座:处女座 生日:8月25日 血型:不明 年龄:2岁 生肖:鸡 身高:120公分 体重:149公斤   职业:机器人 兴趣:周游世界 宠物:变形金刚 最喜欢:充电 最讨厌:拔掉它的电源插头 偶像:科学怪人…
代码: struct NODE{ int to; int nxt; int c; }node[MM];//链式向前星 ; void add(int a,int b,int c){ node[lcnt].to=b; node[lcnt].c=c; node[lcnt].nxt=head[a]; head[a]=lcnt++; } 显示神奇代码 1.使用结构体构建链式向前星的容器 链式向前星本质上是使用链表存边,一条链表代表着一个点发出的所有边.所以一个这个结构体代表着这条链表中的一项 struct…
这道模版用到了链式向前星表示法: struct node { int v,next; }edge[]; void add(int x,int y) { edge[++cnt].next=heads[x]; edge[cnt].v = y; heads[x]=cnt; return ; } 有地方写错了,应该是i=edge[i].next 输入:一个图有向图.输出:它每个强连通分量. input: 6 8 1 3 1 2 2 4 3 4 3 5 4 6 4 1 5 6 output: 6 5 3…
题目: A 国有 n 座城市,n−1 条双向道路将这些城市连接了起来,任何两个城市都可以通过道路互通. 某日,A 国爆发了丧尸危机,所有的幸存者现在都聚集到了 A 国的首都(首都是编号为 1 的城市).而其它城市的丧尸会时不时地向首都发起进攻. 为了抵御丧尸的攻击,幸存者在 A 国的每座城市都修建了防御工事.编号为 i 的城市,其防御工事强度为 di. 当一只丧尸决定进攻首都时,它会从某城市 u(u≠1) 沿经过道路数量最少的路径前往首都.沿途,这只丧尸会试图突破当地的防御工事. 对于某座防御工…
Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several points specializing in the…
POJ 1860 Currency Exchange / ZOJ 1544 Currency Exchange (最短路径相关,spfa求环) Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations onl…
题意:n种钱,m种汇率转换,若ab汇率p,手续费q,则b=(a-q)*p,你有第s种钱v数量,问你能不能通过转化让你的s种钱变多? 思路:因为过程中可能有负权值,用spfa.求是否有正权回路,dis[s]是否增加.把dis初始化为0,然后转化,如果能增大就更新.每次都判断一下dis[s]. 参考:最快最好用的——spfa算法 代码: #include<cstdio> #include<set> #include<vector> #include<cmath>…
Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several points specializing in the same pair o…