
bfs&&dfs
文章平均质量分 57
X~R
这个作者很懒,什么都没留下…
展开
-
Exam Manipulation
题目描述A group of students is taking a True/False exam. Each question is worth one point. You, as theirteacher, want to make your students look as good as possible—so you cheat! (I know, you wouldnever actually do that.) To cheat, you manipulate the answe..原创 2021-04-11 16:59:39 · 253 阅读 · 0 评论 -
结点选择 蓝桥杯
结点选择问题描述有一棵 n 个节点的树,树上每个节点都有一个正整数权值。如果一个点被选择了,那么在树上和它相邻的点都不能被选择。求选出的点的权值和最大是多少?输入格式第一行包含一个整数 n 。接下来的一行包含 n 个正整数,第 i 个正整数代表点 i 的权值。接下来一共 n-1 行,每行描述树上的一条边。输出格式输出一个整数,代表选出的点的权值和的最大值。样例输入51 2 3 4 51 21 32 42 5样例输出12样例说明选择3、4、5号原创 2021-03-04 11:49:59 · 225 阅读 · 1 评论 -
Catch That Cow(广搜)
DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 ≤N≤ 100,000) on a number line and the cow is at a pointK(...原创 2019-12-01 09:23:34 · 164 阅读 · 0 评论 -
深入虎穴
著名的王牌间谍 007 需要执行一次任务,获取敌方的机密情报。已知情报藏在一个地下迷宫里,迷宫只有一个入口,里面有很多条通路,每条路通向一扇门。每一扇门背后或者是一个房间,或者又有很多条路,同样是每条路通向一扇门…… 他的手里有一张表格,是其他间谍帮他收集到的情报,他们记下了每扇门的编号,以及这扇门背后的每一条通路所到达的门的编号。007 发现不存在两条路通向同一扇门。内线告诉他,情报就藏在迷...原创 2019-04-01 23:33:44 · 652 阅读 · 0 评论 -
Prime Ring Problem
A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Note: the number of f...原创 2019-06-02 20:13:27 · 95 阅读 · 0 评论 -
强联通分量
#include<bits/stdc++.h> using namespace std;const int maxn = 1e5 + 10; vector<int> G[maxn]; int DFN[maxn], LOW[maxn], index, cnt;int ans[maxn], belong[maxn];bool vis[maxn];stack...原创 2019-08-13 11:50:37 · 101 阅读 · 0 评论