随笔分类 -  ACM---bfs

1
摘要:n个点最少要n-1条边才能连通,可以删除一条边,最多删除2条边,然后枚举删除的1条边或2条边,用并查集判断是否连通,时间复杂度为O(n^3) 这边犯了个错误, for(int i=0;i<N;i++){ fa[i]=i; } 这个将i<=N,导致错误,值得注意 AC代码: 1 #pragma com 阅读全文
posted @ 2016-02-26 21:40 UniqueColor 阅读(443) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionFat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid o... 阅读全文
posted @ 2015-11-27 22:29 UniqueColor 阅读(270) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionPass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to ... 阅读全文
posted @ 2015-11-17 19:51 UniqueColor 阅读(191) 评论(0) 推荐(0) 编辑
摘要:题目大意:给出一个方格矩阵,矩阵中有数字0~9,任选一个格子为起点,将走过的数字连起来构成一个数,找出最大的那个数,每个格子只能走一次。题目分析:DFS。剪枝方案:在当前的处境下,找出所有还能到达的点的个数,若当前数字的长度加上个数仍小于目前最优答案的长度,则剪去;若长度相等,则将所有还能到达的数字... 阅读全文
posted @ 2015-10-12 20:53 UniqueColor 阅读(439) 评论(0) 推荐(0) 编辑
摘要:DescriptionDrazil created a following problem about putting 1 × 2 tiles into an n × m grid:"There is a grid with some cells that are empty and some ce... 阅读全文
posted @ 2015-09-25 19:54 UniqueColor 阅读(301) 评论(0) 推荐(0) 编辑
摘要:给一个n个点m条边(2 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #in... 阅读全文
posted @ 2015-09-25 11:31 UniqueColor 阅读(304) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionRompire is a robot kingdom and a lot of robots live there peacefully. But one day, the king of Rompire was captured by human beings... 阅读全文
posted @ 2015-09-22 17:03 UniqueColor 阅读(264) 评论(0) 推荐(0) 编辑
摘要:DescriptionFlip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and ... 阅读全文
posted @ 2015-09-15 20:24 UniqueColor 阅读(223) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionDue to the curse made by the devil,Xiao Ming is stranded on a mountain and can hardly escape.This mountain is pretty strange that i... 阅读全文
posted @ 2015-09-12 22:07 UniqueColor 阅读(240) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionTerrorists put some mines in a crowded square recently. The police evacuate all people in time before any mine explodes. Now the po... 阅读全文
posted @ 2015-09-12 14:37 UniqueColor 阅读(343) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionIn an n∗m maze, the right-bottom corner is the exit (position (n,m) is the exit). In every position of this maze, there is either a... 阅读全文
posted @ 2015-09-11 11:26 UniqueColor 阅读(215) 评论(0) 推荐(0) 编辑
摘要:DescriptionDao was a simple two-player board game designed by Jeff Pickering and Ben van Buskirk at 1999. A variation of it, called S-Dao, is a one-pl... 阅读全文
posted @ 2015-09-10 11:26 UniqueColor 阅读(377) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionIgnatius再次被魔王抓走了(搞不懂他咋这么讨魔王喜欢)……这次魔王汲取了上次的教训,把Ignatius关在一个n*m的地牢里,并在地牢的某些地方安装了带锁的门,钥匙藏在地牢另外的某些地方。刚开始Ignatius被关在(sx,sy)的位置,离开地牢的门在(e... 阅读全文
posted @ 2015-09-09 21:29 UniqueColor 阅读(256) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionThe Czech Technical University is rather old — you already know that it celebrates 300 years of its existence in 2007. Some of the ... 阅读全文
posted @ 2015-09-09 20:22 UniqueColor 阅读(200) 评论(0) 推荐(0) 编辑
摘要:DescriptionBessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they ... 阅读全文
posted @ 2015-09-04 22:19 UniqueColor 阅读(227) 评论(0) 推荐(0) 编辑
摘要:DescriptionLet's play a card game called Gap. You have 28 cards labeled with two-digit numbers. The first digit (from 1 to 4) represents the suit of t... 阅读全文
posted @ 2015-08-30 17:52 UniqueColor 阅读(305) 评论(0) 推荐(0) 编辑
摘要:Untrusted PatrolTime Limit:3 Seconds Memory Limit:65536 KBEdward is a rich man. He owns a large factory for health drink production. As a matter of co... 阅读全文
posted @ 2015-08-29 18:37 UniqueColor 阅读(218) 评论(0) 推荐(0) 编辑
摘要:Problem Description《Journey to the West》(also 《Monkey》) is one of the Four Great Classical Novels of Chinese literature. It was written by Wu Cheng'en... 阅读全文
posted @ 2015-08-20 04:47 UniqueColor 阅读(373) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionThere are 2 special dices on the table. On each face of the dice, a distinct number was written. Consider a1.a2,a3,a4,a5,a6to be nu... 阅读全文
posted @ 2015-08-20 02:29 UniqueColor 阅读(225) 评论(0) 推荐(0) 编辑
摘要:DescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled... 阅读全文
posted @ 2015-08-15 18:15 UniqueColor 阅读(241) 评论(0) 推荐(0) 编辑

1
点击右上角即可分享
微信分享提示