201909-2(Python实现)

n = int(input())

dataList = []

for _ in range(n):
    dataList.append( list( map(int, input().split()) ) )

for data in dataList:
    num = data[1]
    drop = False
    for i in range(2,len(data)):
        if data[i]<0 or data[i]==0:
            num += data[i]
        else:
            if num!=data[i]:
                drop = True
            num = data[i]
    data.append(num)
    data.append(drop)

totalNum = 0
dropCount = 0
for _data in dataList:
    totalNum += _data[-2]
    if _data[-1]:
        dropCount += 1

num = 0

for i in range(len(dataList)):
    a1 = i % n
    a2 = (i+1) % n
    a3 = (i+2) % n
    if dataList[a1][-1] and dataList[a2][-1] and dataList[a3][-1]:
        num += 1

print(totalNum, dropCount, num)

你可能感兴趣的:(201909-2(Python实现))