Блог пользователя TomaKapec

Автор TomaKapec, история, 12 месяцев назад, По-английски

So I found fast I/O for Python and I used it before and it worked and now it doesn't. I don't know why, I tried everything! I use it for this task https://mirror.codeforces.com/contest/1850/problem/G, and here is my code. If anyone can explain why that would be great. (To clarify the code may be optimal, or maybe not but the question isn't about the task itself but rather about fast input)

import io, os
#so this here should work but doesn't
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
t = int(input())

def solve(n, points):
    d_plus, d_minus, red, stupac = {}, {}, {}, {}
    r=0
    
    for i in points:
        x, y = i
        a, b, c, d = red.get(x, 0), stupac.get(y, 0), d_plus.get(x+y, 0), d_minus.get(x-y, 0) 
        r+=(a+b+c+d)*2; red[x], stupac[y], d_plus[x+y], d_minus[x-y] = a+1, b+1, c+1, d+1;

    return r

for i in range(t):
    n = int(input())
    points = [list(map(int, (input().decode()).split())) for i in range(n)]
    print(solve(n, points))

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор TomaKapec, история, 12 месяцев назад, По-английски

So I took part in the Codeforces Round 886 for Div4 and quite enjoyed the contest. I was able to solve all but the last problem but unfortunately, my solution for the G task got hacked which was quite annoying then the next day after hacking and system testing it said that my solution for task F also isn't correct and that it TLE-d but during the contest (and after it) It clearly said that my solution is correct. I searched on Google and didn't find anyone with a similar problem. Can anyone explain what happened and is there any way to fix that?

Полный текст и комментарии »

  • Проголосовать: нравится
  • -9
  • Проголосовать: не нравится