摘要:-----------------A. Ciel and Dancingn个男孩和m个女孩配对跳舞,每首歌有一对男女跳舞,要求配对男孩和女孩中至少有一个没有跳过舞。求最多的能放的歌曲数并输出配对方案。分析可知最多能放n+m-1首歌曲。----贪心,男孩1和所有的女孩跳舞。女孩1和所有的男孩跳舞。除去男孩1和女孩1重复的情况#include #include #include using namespace std; int main()
{ int n,m; int s; while (cin>>n>>m) { s=0; ...
阅读全文
摘要:我的模板#include #include #include #include using namespace std; const int maxsize=32; struct Matrix
{ int element[maxsize][maxsize]; int size; int modulo; void init_matrix(int _size,int _modulo) { size=_size; modulo=_modulo; for (int i=0; i
#include ...
阅读全文
摘要:Intersecting LinesTime Limit:1000MSMemory Limit:10000KTotal Submissions:8222Accepted:3746DescriptionWe all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) intersect
阅读全文
摘要:Scrambled PolygonTime Limit:1000MSMemory Limit:30000KTotal Submissions:5868Accepted:2777DescriptionA closed polygon is a figure bounded by a finite number of line segments. The intersections of the bounding line segments are called the vertices of the polygon. When one starts at any vertex of a clos
阅读全文
摘要:WallTime Limit:1000MSMemory Limit:10000KTotal Submissions:25770Accepted:8575DescriptionOnce upon a time there was a greedy King who ordered his chief Architect to build a wall around the King's castle. The King was so greedy, that he would not listen to his Architect's proposals to build a b
阅读全文
摘要:----------#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define mp make_pair
#define pb push_back
using
阅读全文
摘要:DescriptionStan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these sticks such that there is no stick on top of them. Stan has noticed that the last thrown stick is always on top but he
阅读全文
摘要:FlowersTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1829Accepted Submission(s): 901Problem DescriptionAs is known to all, the blooming time and duration varies between different kinds of flowers. Now there is a garden planted full of flowers. Th
阅读全文
摘要:Cut the cakeTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 835Accepted Submission(s): 308Problem DescriptionMark bought a huge cake, because his friend ray_sun’s birthday is coming. Mark is worried about how to divide the cake since it’s so huge a
阅读全文
摘要:Bob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees, factories and buildings. There is still some space in the area that is unoccupied. The strategic task of his game is to w
阅读全文
摘要:问题描述:给定一个N*M的矩阵,其中有一些格子是空地,其他是障碍。找出一个全部由空地组成的面积/周长最大的子矩阵。朴素算法:枚举左上角的坐标O(mn)和右下角的坐标O(mn),判断是否全为空地O(mn),时间复杂度为O(m3*n3)。扫描线法:把点(i,j)向上所有连续的空格看做一条悬线。矩阵中的每个点都向上对应了一条悬线。①用h[i,j]表示点(i,j)对应的悬线长度。当(i,j)为障碍时,h[i,j]=0;当(i,j)为空格时,h[i,j]=h[i-1,j]+1。②用left[i,j]表示点(i,j)对应的悬线的左边界。当(i,j)为障碍时,left[i,j]=左边界;当(i,j)为空格时
阅读全文
摘要:第一章 入门Chapter 1100-The 3n + 1 problem#include #include #include using namespace std; const int maxn=1111111; int f[maxn]; int main()
{ int x,y; int ans,ret; memset(f,0,sizeof(f)); while (~scanf("%d%d",&x,&y)) { ans=0; for (int i=min(x,y);ians) ans=ret; ...
阅读全文
摘要:第一章 入门Chapter 1100-The 3n + 1 problem#include #include #include using namespace std;const int maxn=1111111;int f[maxn];int main(){ int x,y; int ans,ret; memset(f,0,sizeof(f)); while (~scanf("%d%d",&x,&y)) { ans=0; for (int i=min(x,y);ians) ans=ret; } printf...
阅读全文
摘要:Magic NumberTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1113Accepted Submission(s): 480Problem DescriptionThere are many magic numbers whose lengths are less than 10. Given some queries, each contains a single number, if the Levenshtein distanc
阅读全文
摘要:Triangle LOVETime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1629Accepted Submission(s): 693Problem DescriptionRecently, scientists find that there is love between any of two people. For example, between A and B, if A don’t love B, then B must love
阅读全文
摘要:#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define mp make_pair
#define pb push_back
using namespace
阅读全文
摘要:#include #include using namespace std; const int maxn=11111;
const int maxh=10000019;
int head[maxh];
int next[maxh];
long long st[maxn]; void hash_init()
{ memset(head,0,sizeof(head));
} int hash(long long p,int prime=10000019)
{ int h; //hash操作 h=p%prime; return h;
} boo...
阅读全文
摘要:Problem E: Compound WordsYou are to find all the two-word compound words in a dictionary. A two-word compound word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.InputStandard input consists of a number of lowercase words, one per line, in alphabet
阅读全文
摘要:Number GuessingTime Limit 1000msMemory Limit 65536KdescriptionNumber Guessing is a computer game. First, the computer chooses four different digits, you need to guess these four digits in the fewest times,for each guess, the computer will show a judgement in the form of "#A#B", "#&quo
阅读全文
摘要:AnagramTime Limit 4000msMemory Limit 65536KdescriptionYou are to write a program that has to generate all possible words from a given set of letters. Example: Given the word "abc", your program should - by exploring all different combination of the three letters - output the words "ab
阅读全文
摘要:Substrings expTime Limit 1000msMemory Limit 65536KdescriptionYou are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given strings. inputThe first line of the input co...
阅读全文
摘要:Garbage HeapTime limit: ? secondsMemory limit: 64 megabytesFarmer John has a heap of garbage formed in a rectangular parallelepiped.It consists ofgarbage pieces each of which has a value. The value of a piece may be 0, if the piece is neither profitable nor harmful, and may be negative which means t
阅读全文
摘要:Paleontologists in Siberia have recently found a number of fragments of Jurassic period dinosaur skeleton. The paleontologists have decided to forward them to the paleontology museum. Unfortunately, the dinosaur was so huge, that there was no box that the fragments would fit into. Therefore it was d
阅读全文
摘要:Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must defend a medieval city, the roads of which form a tree. He has to put the minimum number of soldiers on the nodes so
阅读全文
摘要:算法设计基础①思维的体操②问题求解常见策略General Problem Solving Techniques③高效算法设计举例Designing Efficient Algorithms④动态规划专题⑤小结与习题暴力NEFU 722 Anagram 全排列 STL枚举UVa 10755 - Garbage Heap 最大子块和 dpNEFU 721 Substrings exp 枚举NEFU 725 Number Guessing 枚举贪心二分回溯线性扫描扫描线法求最大子矩阵递推中途相遇Uva 1326 - Jurassic Remains 中途相遇法哈希哈希模板UVa 10391 - Co
阅读全文
摘要:算法设计基础①思维的体操②问题求解常见策略General Problem Solving Techniques③高效算法设计举例Designing Efficient Algorithms④动态规划专题⑤小结与习题暴力NEFU 722 Anagram 全排列 STL枚举UVa 10755 - Garbage Heap 最大子块和 dpNEFU 721 Substrings exp 枚举NEFU 725 Number Guessing 枚举贪心二分回溯线性扫描扫描线法求最大子矩阵递推中途相遇Uva 1326 - Jurassic Remains 中途相遇法哈希哈希模板UVa 10391 - Co
阅读全文
摘要:Power transmissionTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1403Accepted Submission(s): 533Problem DescriptionThe project West-East power transmission is famous around the world. It transmits the electricity from western areas to east Chin
阅读全文
摘要:The NASA Space Center, Houston, is less than 200 miles from San Antonio, Texas (the site of the ACM Finals this year). This is the place where the astronauts are trained for Mission Seven Dwarfs, the next giant leap in space exploration. The Mars Odyssey program revealed that the surface of Mars is
阅读全文
摘要:A cellular network is a radio network made up of a number of cells each served by a base station located in the cell. The base station receives call signals from mobile users (mobiles) in the cell it serves, which then connects the calls to the wired land-line telephone network. When a call is reque
阅读全文
摘要:Problem FFEWEST FLOPSA common way to uniquely encode a string is by replacing its consecutive repeating characters (or “chunks”) by the number of times the character occurs followed by the character itself. For example, the string “aabbbaabaaaa” may be encoded as “2a3b2a1b4a”. (Note for this problem
阅读全文
摘要:Input: Standard InOutput: Standard OutNext Generation Contest 1Time Limit: 2 secondsProblem DPlacing LamppostsAs a part of the mission �Beautification of Dhaka City�, the government has decided to replace all the old lampposts with new expensive ones. Since the new ones are quite expensive and the b
阅读全文
摘要:Problem HHackers’ CrackdownInput:Standard InputOutput:Standard OutputMiracle Corporations has a number of system services running in a distributed computer system which is a prime target for hackers. The system is basically a set ofNcomputer nodes with each of them running a set ofNservices. Note th
阅读全文
摘要:Problem EGame of SumInput File:e.inOutput:Standard OutputThis is a two player game. Initially there areninteger numbers in an array and playersAandBget chance to take them alternatively. Each player can take one or more numbers from the left or right end of the array but cannot take from both ends a
阅读全文
摘要:int gauss(int r, int c)
{ bool flag=false; int coe=1; int i=0,t=0; for(int j=0; j0) { index=k; break; } if(a[index][j]) { if(index != i) { for(int k=j; k=j; --l) ...
阅读全文
摘要:Save the dwarfsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 934Accepted Submission(s): 285Problem DescriptionSeveral dwarfs are trapped in a deep well. They are not tall enough to climb out of the well, so they want to make a human-pyramid, that
阅读全文
摘要:Meeting point-2Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 889Accepted Submission(s): 485Problem DescriptionIt has been ten years since TJU-ACM established. And in this year all the retired TJU-ACMers want to get together to celebrate the tenth
阅读全文
摘要:MatrixTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1613Accepted Submission(s): 606Problem DescriptionMachines have once again attacked the kingdom of Xions. The kingdom of Xions has N cities and N-1 bidirectional roads. The road network is such
阅读全文
摘要:Meeting point-1Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2324Accepted Submission(s): 735Problem DescriptionIt has been ten years since TJU-ACM established. And in this year all the retired TJU-ACMers want to get together to celebrate the tent
阅读全文
摘要:HeroTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1869Accepted Submission(s): 868Problem DescriptionWhen playing DotA with god-like rivals and pig-like team members, you have to face an embarrassing situation: All your teammates are killed, and y
阅读全文