ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1028. Stars

По дереву Фенвика код не робит
Posted by MuhammaDuMAr 31 Jul 2024 21:39
Здравствуйте! Может кто подсказать, почему код не работает? Специально для задачи изучил дерево Фенвика и на питоне всё равно не заработало (на 9 задаче по времени не прошло)

******************************************************
n=int(input())
mas=[0]*n
xp=[0]*32002
for i in range(n):
    lis=list(map(int,input().split()))                #Принимается на ввод пара координат
    if (lis[0]-1)%4==0:
        if lis[0]!=1:
            mas[xp[lis[0]]+xp[lis[0]-2]]+=1

            for j in range(lis[0]+2,32002,4):
                xp[j]+=1
        else:
            mas[xp[lis[0]]]+=1
            for j in range(lis[0]+2,32002,4):
                xp[j]+=1

    else:
        if (lis[0]+1)%4==0:
            mas[xp[lis[0]]]+=1

            for j in range(lis[0]+4,32002,4):
                xp[j]+=1
        else:
            if lis[0]%2==0:
                if lis[0]!=0:
                    if lis[0]%4==0:
                        mas[xp[lis[0]]+xp[lis[0]-1]]+=1
                        xp[lis[0]+1]+=1
                        for j in range(lis[0]+3,32002,4):
                            xp[j]+=1
                    else:
                        mas[xp[lis[0]+1]-(xp[lis[0]+1]-xp[lis[0]-1]-xp[lis[0]-3])]+=1
                        for j in range(lis[0]+1,32002,4):
                            xp[j]+=1
                else:
                    mas[xp[lis[0]]]+=1
                    xp[lis[0]+1]+=1
                    for j in range(lis[0]+3,32002,4):
                        xp[j]+=1
    xp[lis[0]]+=1
for i in mas:
    print(i)
**************************************