随笔分类 -  DFS

摘要:You are given nn integer numbers a1,a2,…,ana1,a2,…,an. Consider graph on nn nodes, in which nodes ii, jj (i≠ji≠j) are connected if and only if, aiaiAN 阅读全文
posted @ 2019-08-19 20:54 black_hole6 阅读(391) 评论(0) 推荐(0)
摘要:In the year 2008, the 29th Olympic Games will be held in Beijing. This will signify the prosperity of China and Beijing Olympics is to be a festival f 阅读全文
posted @ 2019-07-26 11:17 black_hole6 阅读(180) 评论(0) 推荐(0)
摘要:You are playing a two player game. Initially there are n integer numbers in an array and player A and B get chance to take them alternatively. Each pl 阅读全文
posted @ 2019-07-26 10:31 black_hole6 阅读(205) 评论(0) 推荐(0)
摘要:Jimmy experiences a lot of stress at work these days, especially since his accident made working difficult. To relax after a hard day, he likes to wal 阅读全文
posted @ 2019-05-30 09:40 black_hole6 阅读(264) 评论(0) 推荐(0)
摘要:Chinese Postman Problem is a very famous hard problem in graph theory. The problem is to find a shortest closed path or circuit that visits every edge 阅读全文
posted @ 2019-05-09 21:11 black_hole6 阅读(230) 评论(0) 推荐(0)
摘要:一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。 Input前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m<=20,m>=1.m=0退出. Output输出从第m个城市出发经过每个城市1 阅读全文
posted @ 2019-05-01 11:02 black_hole6 阅读(202) 评论(0) 推荐(0)
摘要:题目描述X星球的机器人表演拉拉队有两种服装,A和B。他们这次表演的是搭机器人塔。类似: A B B A B A A A B B B B B A BA B A B B A队内的组塔规则是: A 只能站在 AA 或 BB 的肩上。 B 只能站在... 阅读全文
posted @ 2019-04-23 23:40 black_hole6 阅读(326) 评论(0) 推荐(0)
摘要:题目描述小明冒充X星球的骑士,进入了一个奇怪的城堡。城堡里边什么都没有,只有方形石头铺成的地面。假设城堡地面是 n x n 个方格。【如图1.png】所示。按习俗,骑士要从西北角走到东南角。可以横向或纵向移动,但不能斜着走,也不能跳跃。每走到一个新方格,就要向正北方和... 阅读全文
posted @ 2019-04-23 11:38 black_hole6 阅读(435) 评论(0) 推荐(0)
摘要:有n种物品,并且知道每种物品的数量。要求从中选出m件物品的排列数。例如有两种物品A,B,并且数量都是1,从中选2件物品,则排列有"AB","BA"两种。 Input每组输入数据有两行,第一行是二个数n,m(1#include#include#include#inclu... 阅读全文
posted @ 2019-04-04 11:01 black_hole6 阅读(274) 评论(0) 推荐(0)
摘要:Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for c... 阅读全文
posted @ 2019-03-27 21:59 black_hole6 阅读(173) 评论(0) 推荐(0)
摘要:可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她... 阅读全文
posted @ 2019-03-25 21:06 black_hole6 阅读(269) 评论(0) 推荐(0)
摘要:Lunar New Year is approaching, and Bob decides to take a wander in a nearby park.The park can be represented as a connected graph with... 阅读全文
posted @ 2019-02-01 23:01 black_hole6 阅读(189) 评论(0) 推荐(0)
摘要:链接:https://ac.nowcoder.com/acm/contest/330/F来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Applese ... 阅读全文
posted @ 2019-01-30 13:46 black_hole6 阅读(206) 评论(0) 推荐(0)
摘要:Description 一个1-n1−n的排列满足所有相邻数字奇偶性不同,那么称该排列为奇偶交错排列。按字典序输出1-n1−n的所有奇偶交错排列。Input 输入一个整数n( 2 \le n \le 11)n(2≤n≤11)Output 输出若干行,每行一个排列。相邻... 阅读全文
posted @ 2019-01-25 21:36 black_hole6 阅读(491) 评论(0) 推荐(0)
摘要:You are given n k-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the ... 阅读全文
posted @ 2019-01-25 18:30 black_hole6 阅读(268) 评论(0) 推荐(0)
摘要:100 可以表示为带分数的形式:100 = 3 + 69258 / 714 还可以表示为:100 = 82 + 3546 / 197 注意特征:带分数中,数字1~9分别出现且只出现一次(不包含0)。 类似这样的带分数,100 有 11 种表示... 阅读全文
posted @ 2019-01-22 13:35 black_hole6 阅读(463) 评论(0) 推荐(0)
摘要:Dreamoon is standing at the position 0 on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon's smartphone a... 阅读全文
posted @ 2019-01-19 17:02 black_hole6 阅读(331) 评论(0) 推荐(0)
摘要:A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is... 阅读全文
posted @ 2019-01-18 11:48 black_hole6 阅读(252) 评论(0) 推荐(0)
摘要:Description 某天GZS漫步在学校新建的小公园,他发现那里建成了一些水池和小河道。我们暂且把它们统一看成水池。假设公园旁有一张小公园的地图,上面仅标识了此处是否是水池,你能帮GZS计算出该地图中一共有几个水池吗。Input第一行输入一个整数N,表示共有N组测... 阅读全文
posted @ 2019-01-09 20:15 black_hole6 阅读(156) 评论(0) 推荐(0)
摘要:There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this "How far ... 阅读全文
posted @ 2018-12-20 13:58 black_hole6 阅读(201) 评论(0) 推荐(0)