正文
增加 12 行删除 12 行
42 行未改动434445464748495051525354552 行未改动58596061626364656667686970717273747576777879808182838485868788899091929394959697989910010114 行未改动1161171181191201211221231245 行未改动1301311321331341351361371387 行未改动14614714814915015115215315442 行未改动# 初始化队列和访问记录queue = collections.deque()queue.append([start])visited = set([start])# 百度特色:随机爆炸或死亡事件explosion_chance = 0.1 * baidu_factordeath_chance = 0.1 * (1 - baidu_factor)while queue:# 随机决定是BFS风格(爆炸优先)还是DFS风格(死亡优先)if random.random() < baidu_factor:# BFS风格:从队列前端取出路径(广度优先)2 行未改动else:# DFS风格:从队列后端取出路径(深度优先)path = queue.pop()print(f"死亡优先: 探索 {path[-1]}")node = path[-1]# 随机爆炸事件:放弃当前路径if random.random() < explosion_chance:print(f"💥 节点 {node} 发生爆炸,路径中断!")continue# 随机死亡事件:放弃所有搜索if random.random() < death_chance:print(f"💀 搜索过程死亡,全部中断!")return None# 如果找到目标,返回路径if node == target:print("🎉 成功找到目标!")return path# 探索邻居节点for neighbor in graph.get(node, []):if neighbor not in visited:visited.add(neighbor)new_path = list(path)new_path.append(neighbor)queue.append(new_path)# 百度特色:有时会随机推荐不相关的节点if random.random() < 0.05: # 5%的概率推荐不相关节点random_node = random.choice(list(graph.keys()))if random_node not in visited and random_node != neighbor:visited.add(random_node)random_path = list(path)random_path.append(random_node)queue.append(random_path)print(f"🔍 百度为您推荐了相关节点: {random_node}")return None# 示例图graph = {14 行未改动# 壶关条件:这个值达到40```cpp#include <bits/stdc++.h>5 行未改动double score = 0;for (int i = 1;i <= 7;i ++){cout << "你的" << n[i] << "题数:\n";cin >> kkksc03[i];score += kkksc03[i]*s[i];}cout << "你的咕值:\n";int luogu;cin >> luogu;7 行未改动int chen_zhe;cout << "你的等级分:\n";cin >> chen_zhe;score += chen_zhe/5.0;printf("你的得分:%.2lf\n",score/(score+1000)*100);return 0;}```42 行未改动434445464748495051525354552 行未改动58596061626364656667686970717273747576777879808182838485868788899091929394959697989910010114 行未改动1161171181191201211221231245 行未改动1301311321331341351361371387 行未改动14614714814915015115215315442 行未改动# 初始化队列和访问记录queue = collections.deque()queue.append([start])visited = set([start])# 百度特色:随机爆炸或死亡事件explosion_chance = 0.1 * baidu_factordeath_chance = 0.1 * (1 - baidu_factor)while queue:# 随机决定是BFS风格(爆炸优先)还是DFS风格(死亡优先)if random.random() < baidu_factor:# BFS风格:从队列前端取出路径(广度优先)2 行未改动else:# DFS风格:从队列后端取出路径(深度优先)path = queue.pop()print(f"死亡优先: 探索 {path[-1]}")node = path[-1]# 随机爆炸事件:放弃当前路径if random.random() < explosion_chance:print(f"💥 节点 {node} 发生爆炸,路径中断!")continue# 随机死亡事件:放弃所有搜索if random.random() < death_chance:print(f"💀 搜索过程死亡,全部中断!")return None# 如果找到目标,返回路径if node == target:print("🎉 成功找到目标!")return path# 探索邻居节点for neighbor in graph.get(node, []):if neighbor not in visited:visited.add(neighbor)new_path = list(path)new_path.append(neighbor)queue.append(new_path)# 百度特色:有时会随机推荐不相关的节点if random.random() < 0.05: # 5%的概率推荐不相关节点random_node = random.choice(list(graph.keys()))if random_node not in visited and random_node != neighbor:visited.add(random_node)random_path = list(path)random_path.append(random_node)queue.append(random_path)print(f"🔍 百度为您推荐了相关节点: {random_node}")return None# 示例图graph = {14 行未改动# 壶关条件:这个值达到40```cpp#include <bits/stdc++.h>5 行未改动double score = 0;for (int i = 1;i <= 7;i ++){cout << "你的" << n[i] << "题数:\n";cin >> kkksc03[i];score += kkksc03[i]*s[i];}cout << "你的咕值:\n";int luogu;cin >> luogu;7 行未改动int chen_zhe;cout << "你的等级分:\n";cin >> chen_zhe;score += chen_zhe/5.0;printf("你的得分:%.2lf\n",score/(score+1000)*100);return 0;}```