POJ 3592 Instantaneous Transference 题目链接 题意:一个图.能往右和下走,然后有*能够传送到一个位置.'#'不能走.走过一个点能够获得该点上面的数字值,问最大能获得多少 思路:因为有环先强连通缩点.然后问题转化为dag,直接dp就可以 代码: #include <cstdio> #include <cstring> #include <vector> #include <algorithm> #include <st…
Instantaneous Transference Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 6204   Accepted: 1389 Description It was long ago when we played the game Red Alert. There is a magic function for the game objects which is called instantaneous…
题目链接 给一个n*m的图, 从0, 0这个点开始走,只能向右和向下. 图中有的格子有值, 求能获得的最大值. 其中有些格子可以传送到另外的格子, 有些格子不可以走. 将图中的每一个格子都看成一个点, 然后对它右边和下边的点连边, 如果是'#’就continue,  如果可以传送, 那么就对传送到的那个点连边, 同时也要向右边和下边连边, 因为可以选择不传送. 然后缩点求最长路就可以. 一个数组没有初始化RE了好多发..... #include <iostream> #include <…
http://poj.org/problem?id=3592 题意 :给你一个n*m的矩阵,每个位置上都有一个字符,如果是数字代表这个地方有该数量的金矿,如果是*代表这个地方有传送带并且没有金矿,可以传送到指定的位置,如果是#代表该位置不可走,初始位置在左上角,只能向下或向右走,并且走到传送带的时候可选择是否传送.问当走出去的时候能获得的最大近况数是多少. 思路 :先将二维矩阵转化成一维的点建图,可以向下向右建图,而且传送带也可以建边,缩点之后再建边,最后用spfa求最长路. #include…
http://poj.org/problem?id=3592 #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #define maxn 300000 using namespace std; <<; ][],num,gg[maxn],point[maxn],cc[maxn],ee,head1[maxn],dis[maxn],cnt[maxn],t…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1179 显然SCC缩点. 然后准备倒着拓扑序推到st,结果WA. 听TJ说dj求最长路会发生不好的事情,于是学TJ用了spfa. 因为是有向边所以别再tarjan里判fa!!! #include<iostream> #include<cstdio> #include<cstring> #include<queue> #define ll long lon…
Every cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <= 50,000) ordered pairs of the form (A, B) that tell you that cow A thinks that cow B is popular. Since pop…
题目描述 约翰有n块草场,编号1到n,这些草场由若干条单行道相连.奶牛贝西是美味牧草的鉴赏家,她想到达尽可能多的草场去品尝牧草. 贝西总是从1号草场出发,最后回到1号草场.她想经过尽可能多的草场,贝西在通一个草场只吃一次草,所以一个草场可以经过多次.因为草场是单行道连接,这给贝西的品鉴工作带来了很大的不便,贝西想偷偷逆向行走一次,但最多只能有一次逆行.问,贝西最多能吃到多少个草场的牧草. 解析 此题就是在Tarjan的板子上玩了点花样,然鹅窝这种题都写不出来,看来我还需要提升. 首先容易看出来一…
//给一个n*m的地图.坦克从(0 , 0)開始走 //#表示墙不能走,*表示传送门能够传送到指定地方,能够选择也能够选择不传送 //数字表示该格的矿石数, //坦克从(0,0)開始走.仅仅能往右和往下走. //问最多能得到多少矿石 //直接建图,但因为有传送门.须要缩点 //然后用dfs直接搜一条权值最大的路 #include<cstdio> #include<cstring> #include<iostream> #include<vector> #in…
Instantaneous Transference Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 6177   Accepted: 1383 Description It was long ago when we played the game Red Alert. There is a magic function for the game objects which is called instantaneous…