随笔分类 - 图论
摘要:题目描述 Byteotia has been eventually touched by globalisation, and so has Byteasar the Postman, who once roamedthe country lanes amidst sleepy hamlets an
阅读全文
摘要:题目描述 Siruseri 城中的道路都是单向的。不同的道路由路口连接。按照法律的规定, 在每个路口都设立了一个 Siruseri 银行的 ATM 取款机。令人奇怪的是,Siruseri 的酒吧也都设在路口,虽然并不是每个路口都设有酒吧。 Banditji 计划实施 Siruseri 有史以来最惊天
阅读全文
摘要:You are given a tree (an undirected acyclic connected graph) with N nodes, and edges numbered 1, 2, 3...N-1. Each edge has an integer value assigned t
阅读全文
摘要:John在他的农场中闲逛时发现了许多虫洞。虫洞可以看作一条十分奇特的有向边,并可以使你返回到过去的一个时刻(相对你进入虫洞之前)。John的每个农场有M条小路(无向边)连接着N (从1..N标号)块地,并有W个虫洞。其中1<=N<=500,1<=M<=2500,1<=W<=200。 现在John想借
阅读全文
摘要:题目描述 输入输出格式 输入格式: 在实际评测时,将只会有m-1行公路 输出格式: 输入输出样例 输入样例#1: 复制 4 2 5 1 2 6 5 1 3 3 1 2 3 9 4 2 4 6 1 输出样例#1: 复制 6 1 1 2 1 4 1样例貌似有点问题;其实就是按照贪心从小到大排序就行了;坑
阅读全文
摘要:就是阶梯NIM博弈,那么看层数是不是奇数的异或就行了;
阅读全文
摘要:题目描述 输入输出格式 输入格式: 输入文件第一行是一个正整数n,表示树有n个结点。第二行有n个数,第i个数表示di,即树的第i个结点的度数。其中1<=n<=150,输入数据保证满足条件的树不超过10^17个。 输出格式: 输出满足条件的树有多少棵。 输入输出样例 输入样例#1: 复制 4 2 1
阅读全文
摘要:题目描述 Bessie is planning the annual Great Cow Gathering for cows all across the country and, of course, she would like to choose the most convenient lo
阅读全文
摘要:There are N towns on a plane. The i-th town is located at the coordinates (xi,yi). There may be more than one town at the same coordinates. You can bu
阅读全文
摘要:A. Salem and Sticks 题目描述 Salem gave you n n n sticks with integer positive lengths a1,a2,…,an a_1, a_2, \ldots, a_n a1,a2,…,an . For every stick, y
阅读全文
摘要:题目描述 小明要去一个国家旅游。这个国家有#NNN个城市,编号为111至NNN,并且有MMM条道路连接着,小明准备从其中一个城市出发,并只往东走到城市i停止。 所以他就需要选择最先到达的城市,并制定一条路线以城市i为终点,使得线路上除了第一个城市,每个城市都在路线前一个城市东面,并且满足这个前提下还
阅读全文
摘要:题目背景 BBB地区在地震过后,所有村庄都造成了一定的损毁,而这场地震却没对公路造成什么影响。但是在村庄重建好之前,所有与未重建完成的村庄的公路均无法通车。换句话说,只有连接着两个重建完成的村庄的公路才能通车,只能到达重建完成的村庄。 题目描述 给出BBB地区的村庄数NNN,村庄编号从000到N−1
阅读全文
摘要:Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own. Ruling a country is not an easy
阅读全文
摘要:Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he
阅读全文
摘要:题目描述 Some company is going to hold a fair in Byteland. There are n n n towns in Byteland and m m m two-way roads between towns. Of course, you can rea
阅读全文
摘要:题目描述 The good folks in Texas are having a heatwave this summer. Their Texas Longhorn cows make for good eating but are not so adept at creating creamy
阅读全文
摘要:题目描述 在这个问题中,给定一个值S和一棵树。在树的每个节点有一个正整数,问有多少条路径的节点总和达到S。路径中节点的深度必须是升序的。假设节点1是根节点,根的深度是0,它的儿子节点的深度为1。路径不必一定从根节点开始。 输入输出格式 输入格式: 第一行是两个整数N和S,其中N是树的节点数。 第二行
阅读全文
摘要:题目描述 小K在MC里面建立很多很多的农场,总共n个,以至于他自己都忘记了每个农场中种植作物的具体数量了,他只记得一些含糊的信息(共m个),以下列三种形式描述: 农场a比农场b至少多种植了c个单位的作物, 农场a比农场b至多多种植了c个单位的作物, 农场a与农场b种植的作物数一样多。 但是,由于小K
阅读全文
摘要:You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn. Write a program that: reads the number of intervals, their end points a
阅读全文
摘要:题目描述 Farmer John has decided to reward his cows for their hard work by taking them on a tour of the big city! The cows must decide how best to spend t
阅读全文