学习小生
学习小生
全部文章
分类
归档
标签
去牛客网
登录
/
注册
学习小生的博客
全部文章
(共36篇)
题解 | 岛屿数量
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # 判断岛屿数量 # @param grid char字符型二维数组 # @return int整型 # from collections import deque class Solution: def...
2025-09-21
0
7
题解 | 买卖股票的最好时机(一)
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param prices int整型一维数组 # @return int整型 # class Solution: def maxProfit(self , prices: List[int])...
2025-09-21
0
5
题解 | 数水坑
from collections import deque n,m = map(int,input().split()) graph = [] for i in range(n): graph.append(list(input())) count = 0 visited = [[False...
2025-09-21
0
5
题解 | 迷宫问题
from collections import deque h,w = map(int,input().split()) arr = [] graph = {} for i in range(h): arr.append(list(map(int,input().split()))) dir...
2025-09-21
0
6
题解 | MOE Top‑k 路由
n,m,p,k = map(int,input().split()) if n % m != 0 or p > m or p*n//m < k: print("error") else: arr = list(map(float,input().spl...
2025-09-07
0
17
题解 | 小红的整数配对
n, k = map(int,input().split()) arr = list(map(int,input().split())) sort_arr = sorted(arr,reverse=True) i = 0 j = 1 visited = set() score = 0 while i...
2025-09-06
1
17
题解 | 小红的矩阵染色
n, m, k = map(int,input().split()) arr = [] for i in range(n): arr.append(list(input())) score = 0 # 求纵向最长的o count_o = {} for i in range(n): f...
2025-09-06
0
18
题解 | 排座椅
n, m, k, l, d = map(int, input().split()) row = {} col = {} for _ in range(d): x, y, p, q = map(int, input().split()) if x == p: min_c...
2025-09-06
1
18
题解 | 全排列
from itertools import permutations n = int(input()) nums = list(range(1, n + 1)) all_permutations = permutations(nums) for perm in all_permutations: ...
2025-09-06
0
17
题解 | 走方格的方案数
n,m = map(int,input().split()) def func(n,m): if n < 0 or m < 0: return 0 elif n == 0 and m == 0: return 1 else: ...
2025-09-06
0
15
首页
上一页
1
2
3
4
下一页
末页