救命,为什么只过了第三个测试点,其他全部WA

P1047 [NOIP2005 普及组] 校门外的树

Xiao_Fun @ 2023-12-03 09:46:46

a = input().split()
l = int(a[0])
m = int(a[1])
num = set()
for i in range(l-1):
    num.add(i)
for i in range(m-1):
    b = input().split()
    b1 = int(b[0])
    b2 = int(b[1])
    for x in range(b1,b2+1):
        if x in num:
            num.remove(x)
        else:
            continue

num1 = len(num)
print(num1)

|