算法:并查集。题意:给你 N 个农场 给定 M 条关系 :x y len dir 表示农场 y 在农场 x 的 dir 方向的 len 米处 输入 Q 个问题:x y index 在知道从从第一条关系到第 index 条关系的情况下,判断农场 x 和农场 y 的相对关系。 如果能判断,则输出相对关系:水平距离差 + 垂直距离差 如果不能判断,则输出 -1.注意:每组测试数据中的每个问题中的 index 是按照从小到大的顺序给出的,所以使得问题简单化。思路:p[] 记录父亲节... Read More
posted @ 2013-04-13 18:56 free斩 Views(159) Comments(0) Diggs(0) Edit
Wireless NetworkTime Limit:10000MSMemory Limit:65536KTotal Submissions:13361Accepted:5659DescriptionAn earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the n Read More
posted @ 2013-04-13 13:07 free斩 Views(216) Comments(0) Diggs(0) Edit
Cube StackingTime Limit:2000MSMemory Limit:30000KTotal Submissions:15951Accepted:5448Case Time Limit:1000MSDescriptionFarmer John and Betsy are playing a game with N (1 const int maxn = 30000+10; int p[maxn]; int r[maxn]; //下面的个数 int sum[maxn]; //总个数 int find(int x) { if(x == p[x]) return x;... Read More
posted @ 2013-04-13 11:47 free斩 Views(230) Comments(0) Diggs(0) Edit