当前位置:网站首页>NLP-D57-nlp比赛D26&刷题D13&读论文&&找了一个多小时bug
NLP-D57-nlp比赛D26&刷题D13&读论文&&找了一个多小时bug
2022-06-22 18:03:00 【甄小胖】
——早上扫完三篇论文,下意识打开微信读书,又加了几本好书。现在总是觉得读书的时间是宝贵的、温暖的,希望能给自己的心灵留一块空地,也许是一片绿荫。现在开始刷题了!
2816双指针

803区间合并
n = int(input())
a = []
res = []
for _ in range(n):
a.append(list(map(int,input().split())))
res.append(a[0])
# 区间合并算法需要先根据第一个点的值进行排序,
# 不然就是一顿操作猛如虎
a.sort()
for i in range(1,n):
if res[-1][1]>=a[i][0]:
res[-1][1] = max(res[-1][1],a[i][1])
else:
res.append(a[i])
print(len(res))
双链表
找bug真让人想吐
我吐了,找了半个小时,照不出来
m = int(input())
h,t = 0,1
r,l,e= [0]*100010,[0]*100010,[0]*100010
l[1]=0
r[0]=1
idx = 2
def add_to_k(x,k):
global idx
# 从右侧插入
e[idx] =x
l[idx] = k+1
r[idx] = r[k+1]
l[r[k+1]] = idx
r[k+1] = idx
idx+=1
def remove(k):
r[l[k+1]] = r[k+1]
l[r[k+1]]=l[k+1]
for _ in range(m):
op,*pt = input().split()
# *pt取值时用pt[0]
if op=='L':
add_to_k(int(pt[0]),0)
elif op=='R':
add_to_k(int(pt[0]),l[1])
elif op=='D':
remove(int(pt[0]))
elif op=='IL':
k,x = map(int,pt)
add_to_k(x,l[k])
else:
k,x = map(int, pt)
add_to_k(x,k)
# 先指向第一个
h =r[h]
while h!=1:
# print(h)
# print(2)
print(e[h], end=' ')
h = r[h]
改了一点,还是错
m = int(input())
h,t = 0,1
r,l,e= [0]*100010,[0]*100010,[0]*100010
l[1]=0
r[0]=1
idx = 2
def add_to_k(x,k):
global idx
# 从右侧插入
e[idx] =x
l[idx] = k+1
r[idx] = r[k+1]
l[r[k+1]] = idx
r[k+1] = idx
idx+=1
def remove(k):
r[l[k+1]] = r[k+1]
l[r[k+1]]=l[k+1]
for _ in range(m):
op,*pt = input().split()
# *pt取值时用pt[0]
if op=='L':
add_to_k(int(pt[0]),-1)
elif op=='R':
add_to_k(int(pt[0]),l[1])
elif op=='D':
remove(int(pt[0]))
elif op=='IL':
k,x = map(int,pt)
add_to_k(x,l[k])
else:
k,x = map(int, pt)
add_to_k(x,k)
# 先指向第一个
h =r[h]
print(r)
# print(l)
while h!=1:
# print(h)
# print(2)
print(e[h], end=' ')
h = r[h]
放弃了,直接用原来的思路写叭,快一个小时了。
把k+1改为k就好了。
我感觉还是用k作为编号,后期调用函数的时候再考虑第k个的编号是几比较好。因为头结点和尾结点的操作都是以编号为标准进行的,如果函数的定义为第几个插入的话,对于头尾结点不好转换。所以,k也就是函数参数还是定义为idx编号比较好。
记住:双链表函数中的k是idx编号,第k个插入,其idx编号是k+1!!!记住!!
要开始记录一些常用df操作了
df[‘’].value_counts()
统计某一列值的种类和对应个数
边栏推荐
- 机械设备行业数字化供应链集采平台解决方案:优化资源配置,实现降本增效
- 面试MySQL
- 将一维数据(序列)转化为二维数据(图像)的方法汇总GAFS, MTF, Recurrence plot,STFT
- Pull down refresh and pull up to load more listviews
- Play typical usage scenarios of kubernetes | dashboard for 5 minutes every day
- Paopao Mart: empty souls need stories
- 消息中间件(一)MQ详解及四大MQ比较
- Flush difficult to open an account? Is it safe to open an account online?
- Iplook, as a member of o-ran alliance, will jointly promote the development of 5g industry
- Implementing Domain Driven Design - using ABP framework - solution overview
猜你喜欢
随机推荐
Shell programming specification and variables
实验4 NoSQL和关系数据库的操作比较
Screw数据库文档生成器
Detailed explanation of shell script (x) -- how to use sed editor
Makefile将某一部分文件不编译
Error in created hook: “TypeError: Cannot read property ‘tableId‘ of undefined“
jniLibs. Srcdirs = ['LIBS'] what's the use?
上半年,这个领域竟出了7家新独角兽,资本争抢入局
缓存3种方式及原理
Flutter series - build a flutter development environment
Aiops intelligent operation and maintenance experience sharing
Iplook 5gc successfully connected with CICA international CHF (billing function)
org. apache. ibatis. binding. BindingException: Invalid bound statement (not found)
Service实战:使用Service完成一个下载任务
PLSQL variable assignment
STM32 control matrix key, Hal library, cubemx configuration
实验七 触发器
Digital business cloud: build a digital supply chain system to enable enterprises to optimize and upgrade their logistics supply chain
IPLOOK 5GC与亚信国际CHF(计费功能)对接成功
牛客网:合并区间







![jniLibs.srcDirs = [‘libs‘]有什么用?](/img/d5/3070f8e793507efc601bb22d5024fa.png)

