现在位置: 首页 > 算法 > 文章
2017年07月28日 算法 ⁄ 共 202字 评论关闭
#include #include int main(){ int g=0,m,n,i; char a[3][15];a[0][0]='\0'; while(gets(a[1])&&a[1][0]){         m=strlen(a[0]),n=strlen(a[1]); for(i=0;i if(i>g) g++; else g=i; for(i=0;i puts(a[1]); strcpy(a[0],a[1]); } return 0; }
阅读全文
2017年07月15日 算法 ⁄ 共 1475字 评论关闭
题意:求解点v可达的点都能到达v的点的集合 只需要求出出度为0的强连通分量输出即可。属于简单模板题~~~ #include <iostream> #include <vector> #include <stack> #include <string.h> #include <stdio.h> #include <algorithm> using namespace std; const int N=5005; int vN,e; vector <int >grap[N]; stack<int> s; int low[N]; int num[N]; int visited[N]; int ins...
阅读全文
2017年07月15日 算法 ⁄ 共 1894字 评论关闭
此题一直WA,此为WA的代码,哪位神牛级的人物帮我解答一下,在下不胜感激!!!! #include <algorithm> #include <iostream> #include <string.h> #include <stdio.h> #include <math.h> #include <map> #include <vector> #include <queue> #include <stack> using namespace std; const int N=1150; int inf=1000000000; map<string ,int >mp; int p,n,...
阅读全文
2017年06月07日 算法 ⁄ 共 2002字 评论关闭
Best Cow Line Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10605   Accepted: 3189 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them past the judges. The contest organizers adopted a new registration scheme this year: simply register the ini...
阅读全文
2017年06月07日 算法 ⁄ 共 2073字 评论关闭
Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4250   Accepted: 2183 Description Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effective range of R units, and must be carried by so...
阅读全文
2017年06月06日 算法 ⁄ 共 2183字 评论关闭
Fence Repair Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 27280   Accepted: 8875 Description Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer length Li (1 ≤ Li ≤ 50,000) units. He then purchases a single long board just long enough to...
阅读全文
2017年06月04日 算法 ⁄ 共 2464字 评论关闭
COURSES Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 15655   Accepted: 6185 Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is possible to form a committee of exactly P students that satisfies simultaneously the conditions:  every student in the committee represen...
阅读全文
2017年06月04日 算法 ⁄ 共 1056字 评论关闭
http://poj.org/problem?id=3041 最小覆盖: 最小覆盖要求用最少的点(X集合或Y集合的都行)让每条边都至少和其中一个点关联。 可以证明:最少的点(即覆盖数)=最大匹配数 M 简单的证明如下: (1)M个是足够的。只需要让它们覆盖最大匹配的M条边,则其它边一定被覆盖(如果有边e不被覆盖,把e加入后得到一个更大的匹配) (2)M个是必需的,仅考虑形成最大匹配的这M条边,由于它们两两之间没有公共点,因此至少需要M个点...
阅读全文
2017年06月04日 算法 ⁄ 共 1131字 评论关闭
排列 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 14758 Accepted: 5988 Description 题目描述: 大家知道,给出正整数n,则1到n这n个数可以构成n!种排列,把这些排列按照从小到大的顺序(字典顺序)列出,如n=3时,列出1 2 3,1 3 2,2 1 3,2 3 1,3 1 2,3 2 1六个排列。 任务描述: 给出某个排列,求出这个排列的下k个排列,如果遇到最后一个排列,则下1排列为第1个排列,即排列1 2 3…n。...
阅读全文
2017年06月04日 算法 ⁄ 共 3444字 评论关闭
The Unique MST Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 17881 Accepted: 6204 Description Given a connected undirected graph, tell if its minimum spanning tree is unique. Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A spanning tree of G is a subgraph of G, say T = (V', E'), with the following properties: 1. V' = V. 2. T is conne...
阅读全文