随笔分类 -  ACM - 解题报告

摘要:#include<stdlib.h>#include<string.h>#include<stdio.h>#include<math.h>#include<queue>#define MAXN 1005using namespace std;int root[MAXN];struct edge{ int head; int tail; int cost; friend bool operator< (const edge &e1,const edge &e2){ return e1.cost > e2.co 阅读全文
posted @ 2013-04-30 01:26 kahreman 阅读(300) 评论(0) 推荐(0)
摘要:#include<stdlib.h>#include<string.h>#include<stdio.h>#include<math.h>#include<queue>#define MAXN 105using namespace std;int root[MAXN];struct edge{//定义边结构体 int head;//边头 int tail;//边尾 int cost;//花费 friend bool operator< (const edge &e1,const edge &e2){ //定义比较 阅读全文
posted @ 2013-04-28 22:02 kahreman 阅读(219) 评论(0) 推荐(0)
摘要:#include<stdlib.h>#include<string.h>#include<stdio.h>#include<math.h>#define MAXN 105#define inf 1000000000typedef double elem;elem prim(int n,elem mat[][MAXN]){ elem min[MAXN],ret=0; int v[MAXN],i,j,k; for (i=0;i<n;i++) min[i]=inf,v[i]=0; for (min[j=0]=0;j<n;j++){ for 阅读全文
posted @ 2013-04-28 13:27 kahreman 阅读(206) 评论(0) 推荐(0)
摘要:强连通分量计数#include<stdlib.h>#include<string.h>#include<stdio.h>int root[1010];int n,m;int findroot(int index){ if(root[index] == -1) return index; else return findroot(root[index]);}int main(){ int i; int j; int bufx,bufy; freopen("in_kruskal.txt","r",stdin); freop 阅读全文
posted @ 2013-04-26 19:44 kahreman 阅读(343) 评论(0) 推荐(0)
摘要:猜数字Time Limit: 20000/10000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1391Accepted Submission(s): 798Problem Description猜数字游戏是gameboy最喜欢的游戏之一。游戏的规则是这样的:计算机随机产生一个四位数,然后玩家猜这个四位数是什么。每猜一个数,计算机都会告诉玩家猜对几个数字,其中有几个数字在正确的位置上。比如计算机随机产生的数字为1122。如果玩家猜1234,因为1,2这两个数字同时存在于这两个数中, 阅读全文
posted @ 2012-09-21 20:24 kahreman 阅读(840) 评论(0) 推荐(0)
摘要:DescriptionBusinesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by dialing the memorable TUT-GLOP. Sometimes only part of the number is used to spell a wo 阅读全文
posted @ 2011-08-12 01:38 kahreman 阅读(369) 评论(0) 推荐(0)
摘要:DescriptionWelcome to the Annual Byteland Shooting Contest. Each competitor will shoot to a target which is a rectangular grid. The target consists of r*c squares located in r rows and c columns. The squares are coloured white or black. There are exactly two white squares and r-2 black squares in ea 阅读全文
posted @ 2011-08-10 17:18 kahreman 阅读(234) 评论(0) 推荐(0)
摘要:DescriptionConsider 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 represents a differe 阅读全文
posted @ 2011-08-10 16:13 kahreman 阅读(302) 评论(0) 推荐(0)
摘要:DescriptionConsider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersection and walking through town's streets you can never reach the same intersection i.e. the town's streets form no cycles.With th 阅读全文
posted @ 2011-08-10 15:06 kahreman 阅读(214) 评论(0) 推荐(0)
摘要:棋盘覆盖问题 问题描述: 在一个2^k×2^k个方格组成的棋盘中,若有一个方格与其他方格不同,则称该方格为一特殊方格,且称该棋盘为一个特殊棋盘.显然特殊方格在棋盘上出现的位置有4^k种情形.因而对任何k≥0,有4^k种不同的特殊棋盘. 下图–图(1)中的特殊棋盘是当k=3时16个特殊棋盘中的一个:图(1) 题目要求在棋盘覆盖问题中,要用下图-图(2)所示的4种不同形态的L型骨牌覆盖一个给定的特殊棋盘上除特殊方格以外的所有方格,且任何2个L型骨牌不得重叠覆盖.图(2)题目包含多组测试数据,输入包含测试数据组数N,下面输入N组数据,每组数据,包括边长m和特殊方格的位置x,y。input 阅读全文
posted @ 2011-08-08 10:09 kahreman 阅读(14320) 评论(1) 推荐(1)
摘要:Problem Description当今国际反恐形势很严峻,特别是美国“9.11事件”以后,国际恐怖势力更是有恃无恐,制造了多起骇人听闻的恐怖事件。基于此,各国都十分担心恐怖势力会对本国社会造成的不稳定,于是纷纷在本国的军队、警察队伍中开展了反恐训练。作为反恐立场坚定的大国,中国也十分重视在人民解放军、武装警察部队、人民警察队伍中反恐训练,还专门成立了反恐特警队。炜炜是反恐特警队的一名新队员,现在正在接受培训。这几天刚好是射击训练第二阶段——实弹应变训练的日子,此前的第一阶段里,炜炜经过努力,已经将自己训练成为一个百发百中的神抢手了!这次,他将背着国产最新型12.7mm重型狙击枪进行训练比赛 阅读全文
posted @ 2011-08-05 03:03 kahreman 阅读(312) 评论(0) 推荐(0)
摘要:Problem DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another sequence Z = <z1, z2, ..., zk> is a subsequence of X if there exists a strictly increasing sequence <i1, i2, ..., ik&g 阅读全文
posted @ 2011-08-04 20:03 kahreman 阅读(364) 评论(0) 推荐(0)
摘要:Problem Description给你n个整数,请按从大到小的顺序输出其中前m大的数。Input每组测试数据有两行,第一行有两个数n,m(0<n,m<1000000),第二行包含n个各不相同,且都处于区间[-500000,500000]的整数。Output对每组测试数据按从大到小的顺序输出前m大的数。Sample Input5 33 -35 92 213 -644Sample Output213 92 3#include<stdio.h>#include<stdlib.h>#include<time.h>#define N 1000050in 阅读全文
posted @ 2011-08-04 19:47 kahreman 阅读(1402) 评论(0) 推荐(0)
摘要:Problem DescriptionXX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每一条路有一个安全系数s,s是在 0 和 1 间的实数(包括0,1),一条从u 到 v 的通道P 的安全度为Safe(P) = s(e1)*s(e2)…*s(ek) e1,e2,ek是P 上的边 ,现在8600 想出去旅游,面对这这么多的路,他想找一条最安全的路。但是8600 的数学不好,想请你帮忙 ^_^Input输入包括多个测试实例,每个实例包括:第一行:n。n表示城市的个数n<=1000;接着是一个n*n的矩阵表示两个城市之间的安全系数,(0可以理解为那两个城 阅读全文
posted @ 2011-08-04 19:39 kahreman 阅读(681) 评论(0) 推荐(0)
摘要:Problem DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Farmer John has built a set of drainage ditches so that Bessie's clover 阅读全文
posted @ 2011-08-04 19:31 kahreman 阅读(440) 评论(0) 推荐(0)