一個簡單的並查集的運用、、、找到與第一個有關係的人、、#include <stdio.h>#include <stdlib.h>#define MAXN 30010int p[MAXN];int find_f(int x){ return p[x] == x ? x : (find_f(p[x]));}void rank(int a, int b){ int x = find_f(a), y = find_f(b); if(x != y) p[x] =
Can you answer these queries?Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 6849 Accepted Submission(s): 1566Problem DescriptionA lot of battleships of evil are arranged in a line before
第一道額~~#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int MAXN=100005;struct node{ int l,r; int lsum,rsum,msum; int mid() { return (l+r)>>1; }};node tree[MAXN*4];inline
Phone ListTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 18122 Accepted: 5769DescriptionGiven a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the phone catalogue
原題連結:http://poj.org/problem?id=3278演算法:bfs+隊列+STL(C++)PS:bfs入門題目,好高興啊,終於會用bfs了。Catch That CowTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 32679 Accepted: 10060DescriptionFarmer John has been informed of the location of a fugitive cow
連結:http://poj.org/problem?id=2251http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22009#problem/EDungeon MasterTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 14103 Accepted: 5477DescriptionYou are trapped in a 3D dungeon and need to
這是一道典型的map但也可以用字典樹與排序二叉樹A、、、嘿嘿題目描述You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them. 輸入Input consists of up to 100,
連結:http://poj.org/problem?id=1050http://acm.hust.edu.cn/vjudge/contest/view.action?cid=28508#problem/BTo the MaxTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 36968 Accepted: 19480DescriptionGiven a two-dimensional array of positive and