lotusor
lotusor
全部文章
分类
归档
标签
去牛客网
登录
/
注册
lotusor的博客
全部文章
(共10篇)
题解 | 小红的口罩
这题可以使用内置库中的优先队列来解决,我们知道优先队列中heap[0]为最小值,并且只需初始化一次,我们只需要每次提取min再将min修改后放回即可,正好符合本题的要求,关于优先队列的知识大家可以自行了解 import heapq n,k = map(int,input().split()) lis...
2025-12-19
1
20
题解 | 括号的匹配
n = int(input()) dic0 = {"{":"}","[":"]","(":")","<":">"} dic1 =...
2025-12-18
0
20
题解 | 点击消除
s = input() stack = [] for i in s: if not stack : stack.append(i) else : if stack[-1] == i : stack.pop(-1) ...
2025-12-09
0
24
题解 | 小红的异或构造
n = int(input()) C = n+1 ans = [C ^ i for i in range(1, n + 1)] print(' '.join(map(str, ans))) 本题需要用到异或的数学性质,不难发现本题的构造可以改写为ai异或i = aj 异或j,这就表明数列的所有异或结...
2025-12-07
0
29
题解 | 构造序列
n,m = map(int,input().split()) if m==n: print(m*2) elif m==0 or n==0: print(1) else : print(min(n,m)*2+1)
2025-12-06
0
24
题解 | 如果直接枚举所有的肯定会超时,所以要先预处理记录#的位置
n = int(input()) list0 = [list(input().strip()) for _ in range(n)] # 收集所有#的位置 points = [] for i in range(n): for j in range(n): if list0[i...
2025-12-06
0
24
题解 | 简单的常规模拟
n = int(input()) s = input().split() new = "" for i in range(len(s)): if s[i] == "0" : continue else : p =...
2025-12-06
0
21
题解 | 铺地毯
import sys n = int(input()) list0 = [list(map(int, input().split())) for i in range(n)] x,y = map(int, input().split()) t = -1 for j in range(n): ...
2025-12-02
0
25
题解 | 排序危机之利用py的异常机制的一个很邪门的解法
#很不推荐大家在正赛用try,有点不规范,但可以开阔下思路( a = int(input()) n = input() low = "" up = "" num = "" for i in n: try : p = ...
2025-12-02
1
26
题解 | 添加逗号
n = input() m = n[::-1] count = 0 s = "" for i in m: count += 1 if count % 3 == 0 and count != len(m): s += i + ","...
2025-12-02
0
28