답안 #973912

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973912 2024-05-02T12:47:31 Z jakobrs Spiral (BOI16_spiral) Python 3
0 / 100
14 ms 3164 KB
def E(p,n):return sum(v*n**i for i,v in enumerate(p)) 
def r(x,y):
 X=abs(x);Y=abs(y);n=min(X,Y);N=max(X,Y);L=X<Y;rp=[[[13,15,8],[19,-21,8]],[[19,21,8],[13,-15,8]]][L][[x,y][L]>=0];f=n-([y,x][L]>=0)
 return (E([[[-1,2,4,2],[0,4,0,2]],[[-4,10,0,2],[1,2,-4,2]]][x>=0][y>=0],n)+(N*E(rp,N)-n*E(rp,n))//6)*n+((N-n)*f*(f+1))//2*(-1 if(L!=(x >= 0))!=(y>=0)else 1)-8*y*(0<-y<x)
def R(p,q,X,Y):
 X+=1;Y+=1;x=[p,X];y=[q,Y];return sum(r(x[a],y[b])*(1 if(p*X>0 and(abs(X)<abs(p))==a)==(q*Y>0 and(abs(Y)<abs(Q))==b)else -1) for a,b in[(0,0),(0,1),(1,0),(1,1)])%(10**9+7)
I=input
for i in range(int(I().split()[1])):
 print(R(*map(int,I().split())))
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 3116 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 2908 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 3116 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 14 ms 3164 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 3116 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -