POJ 3180】的更多相关文章

http://poj.org/problem?id=3180 The Cow Prom Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1428   Accepted: 903 Description The N (2 <= N <= 10,000) cows are so excited: it's prom night! They are dressed in their finest gowns, complete…
[题目链接] http://poj.org/problem?id=3180 [题目大意] N头牛,M条有向绳子,能组成几个歌舞团?要求顺时针逆时针都能带动舞团内所有牛. [题解] 等价于求点数大于1的SCC数量. [代码] #include <cstdio> #include <algorithm> #include <vector> #include <cstring> using namespace std; const int MAX_V=10000;…
The Cow Prom Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1132   Accepted: 713 Description The N (2 <= N <= 10,000) cows are so excited: it's prom night! They are dressed in their finest gowns, complete with corsages and new shoes. T…
题目大意: 约翰的N(2≤N≤10000)只奶牛非常兴奋,因为这是舞会之夜!她们穿上礼服和新鞋子,别上鲜花,她们要表演圆舞.           只有奶牛才能表演这种圆舞.圆舞需要一些绳索和一个圆形的水池.奶牛们围在池边站好,顺时针顺序由1到N编号.每只奶牛都面对水池,这样她就能看到其他的每一只奶牛.为了跳这种圆舞,她们找了M(2≤M≤50000)条绳索.若干只奶牛的蹄上握着绳索的一端,绳索沿顺时针方绕过水池,另一端则捆在另一些奶牛身上.这样,一些奶牛就可以牵引另一些奶牛.有的奶牛可能握有很多绳…
Description The N ( <= N <= ,) cows are so excited: it's prom night! They are dressed in their finest gowns, complete with corsages and new shoes. They know that tonight they will each try to perform the Round Dance. Only cows can perform the Round…
原题 这是一道强连通分量板子题. 我们只用输出点数大于1的强连通分量的个数! #include<cstdio> #include<algorithm> #include<stack> #define N 10010 #define M 50010 using namespace std; int n,m,head[N],dfn[N],low[N],cnt=1,t,sum,bel[N],num[N],out[N],ans; bool instk[N]; stack <…
题目用google翻译实在看不懂 其实题目意思如下 给一个有向图,求点个数大于1的强联通分量个数 #include<cstdio> #include<algorithm> #include<cstring> #include<vector> #include<stack> #define M 50010 #define N 10010 using namespace std; ,ans,sz[N],belong[N],dfn[N],low[N],…
题意:找强连通中点数大于2的强连通分量个数 思路:Tarjan // By SiriusRen #include <cstdio> #include <algorithm> using namespace std; int n,m,ans=0,t=0,cnt=0,tot=1,top=0,dfn[50050],low[50050],p[10050],s[10050]; int xx,yy,jy,first[10050],next[50050],v[50050]; bool vis[5…
题意:一群牛被有向的绳子拴起来,如果有一些牛(>=2)的绳子是同向的,他们就能跳跃.求能够跳跃的组数. #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <queue> #include <stack> #includ…
这几天一直在做强连通,现在总结一小下 1.定义 在一个有向图中,如果任意的两个点都是相互可达的,就说这个图是强连通的,有向图的极大强连通子图,称为强连通分量 2.求法 学的是白书上的tarjan算法 用到了DFS的时间戳 假设一个强连通分量C,其中的第一个点是 P,那么DFS下去,就一定能够找到一个K点,返回P点,这条DFS路径上的点就处于这个强连通分量C中 假如现在发现节点v,同时发现节点v最远只能够到达节点u,那么节点u就是这个强连通分量最先被发现的节点 这样就转化成了求一个点u最远能够到达…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i…
Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798   Special Judge Description Every year there is the same problem at Halloween: Each neighbour is only willing to give a certain total number of sweets…
Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   Special Judge Description The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286   Accepted: 8603   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the…
Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yumm…
Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050   Accepted: 10989 Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representatio…
Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 Description Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital le…
Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17898   Accepted: 9197 Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names t…
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时则按照横坐标从小到大输出. (0 <= x, y <= 32000) 要求输出等级0到n-1之间各等级的星星个数. 分析: 这道题不难想到n平方的算法,即从纵坐标最小的开始搜,每次找它前面横坐标的值比它小的点的个数,两个for循环搞定,但是会超时. 所以需要用一些数据结构去优化,主要是优化找 横坐…
poj   1251  Jungle Roads  (最小生成树) Link: http://poj.org/problem?id=1251 Jungle Roads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23507   Accepted: 11012 Description The Head Elder of the tropical island of Lagrishan has a problem. A b…
Kaka's Matrix Travels Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9567   Accepted: 3888 Description On an N × N chessboard with a non-negative number in each grid, Kaka starts his matrix travels with SUM = 0. For each travel, Kaka mo…
Friendship Time Limit: 2000MS   Memory Limit: 20000K Total Submissions: 10626   Accepted: 2949 Description In modern society, each person has his own friends. Since all the people are very busy, they communicate with each other only by phone. You can…
Ikki's Story I - Road Reconstruction Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 7659   Accepted: 2215 Description Ikki is the king of a small country – Phoenix, Phoenix is so small that there is only one city that is responsible fo…
http://poj.org/problem?id=1144 题意:给你一些点,某些点直接有边,并且是无向边,求有多少个点是割点 割点:就是在图中,去掉一个点,无向图会构成多个子图,这就是割点 Tarjan算法求割点的办法 如果该点为根,那么它的子树必须要大于1 如果该点不为根,那么当low[v]>=dnf[u]时,为割点 Low[v]>=dnf[u]也就是说明U的子孙点只能通过U点访问U的祖先点 #include <stdio.h> #include <stack>…
http://poj.org/problem?id=3614 题意:有n头奶牛想要晒太阳,但他们每个人对太阳都有不同的耐受程度,也就是说,太阳不能太大也不能太小,现在有一种防晒霜,涂抹这个防晒霜可以把太阳的强度固定到一个值 求一共有多少头奶牛可以晒太阳 #include <stdio.h> #include <queue> #include <stdlib.h> using namespace std; int m,n; struct co{ int mi,ma; }c…
POJ 3669 去看流星雨,不料流星掉下来会砸毁上下左右中五个点.每个流星掉下的位置和时间都不同,求能否活命,如果能活命,最短的逃跑时间是多少? 思路:对流星雨排序,然后将地图的每个点的值设为该点最早被炸毁的时间 #include <iostream> #include <algorithm> #include <queue> #include <cstring> using namespace std; #define INDEX_MAX 512 int…
POJ 3009 题意: 给出一个w*h的地图,其中0代表空地,1代表障碍物,2代表起点,3代表终点,每次行动可以走多个方格,每次只能向附近一格不是障碍物的方向行动,直到碰到障碍物才停下来,此时障碍物也会随之消失,如果行动时超出方格的界限或行动次数超过了10则会game over .如果行动时经过3则会win,记下此时行动次数(不是行动的方格数),求最小的行动次数 #include<cstdio> #include<iostream> #include<cstring>…
更新中... http://poj.org/problem?id=1037 dp[i][j][0]表示序列长度为i,以j开始并且前两位下降的合法序列数目; dp[i][j][1]表示序列长度为i, 以j开始并且前两位上升的合法序列数目; 于是我们可以得到递推方程式:dp[i][j][0] += dp[i-1][k][1] ( 1 <= k < j ), dp[i][j][1] += dp[i-1][k][0] ( k <= j <= i), 然后我们就可以从第一位开始枚举了. ht…
SudoKu Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu POJ 2676 Description Sudoku is a very simple task. A square table with 9 rows and 9 columns is divided to 9 smaller squares 3x3 as shown on the Figure. In some of the c…