2.危险系数 - 蓝桥云课 (lanqiao.cn)
n, m = map(int, input().split()) map_ = [[] for i in range(n + 1)] used = [0 for i in range(n + 1)] used_ = [0 for i in range(n + 1)] cnt = 0 res = [] for _ in range(m):u, v = map(int, input().split())map_[u].append(v)map_[v].append(u)u, v = map(int, input().split())def dfs(u, v):global cntif u == v:cnt += 1for i in res:used_[i] += 1returnfor i in map_[u]:if not used[i]:used[i] = 1res.append(i)dfs(i, v)res.pop()used[i] = 0dfs(u, v) ans = 0 for i in range(1, n + 1):if used_[i] == cnt and i != u and i != v:ans += 1 print(ans)
3.串变换 - 蓝桥云课 (lanqiao.cn)
def op(z, x, y_v, arr):if z == 1:arr[x] = (int(arr[x]) + y_v) % 10else:arr[x], arr[y_v] = arr[y_v], arr[x]# 输入 n = int(input()) s = list(input()) t = list(input()) k = int(input()) k_ = [] used = [0 for _ in range(k)] for _ in range(k):a, b, c = map(int, input().split())k_.append((a, b, c))# print(k_) j = Falsedef dfs(index, s):global jif index == k:returnfor i in range(k):if not used[i]:tmp = sused[i] = 1op(k_[i][0], k_[i][1], k_[i][2], s)if not j:l = 0for x in range(n):if int(s[x]) != int(t[x]):l = 1breakif not l:j = Trueelse:returndfs(index + 1, s)s = tmpused[i] = 0dfs(0, s) if j:print("Yes") else:print("No")
8.仙境诅咒 - 蓝桥云课 (lanqiao.cn)
import os
import sys
# 请在此输入您的代码
n = int(input())
man = []
for _ in range(n):
x, y = map(int, input().split())
man.append([x, y])
D = int(input())
man_used = [0 for _ in range(n)]
def dfs(index):
man_used[index] = 1
for i in range(n):
if not man_used[i]:
r_ = (man[i][0] - man[index][0]) ** 2 + (man[i][1] - man[index][1]) ** 2
if r_ <= D * D:
dfs(i)
dfs(0)
for i in man_used:
if i:
print(1)
else:print(0)