Submission #19514403


Source Code Expand

Copy
from collections import defaultdict
import math
mod=10**9+7
n=int(input())
P=defaultdict(int)
M=defaultdict(int)
c=0
for _ in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        c+=1
        continue
    elif a==0:
        if b<0:
            M[(1,0)]+=1
        else:
            P[(0,1)]+=1
        continue
    elif b==0:
        if a<0:
            M[(0,1)]+=1
        else:
            P[(1,0)]+=1
        continue
    g=math.gcd(a,b)
    a,b=a//g,b//g
    if a*b<0:
        M[(abs(b),abs(a))]+=1
    else:
        P[(a,b)]+=1
D_pow=dict()
def my_pow(k):
    if k in D_pow:
        return D_pow[k]
    else:
        D_pow[k]=pow(2,k,mod)
        return D_pow[k]
ans=1
for k in P.keys():
    if k in M:
        tmp=my_pow(P[k])+my_pow(M[k])-1
        tmp%=mod
        ans*=tmp
        ans%=mod
        M[k]=0
    else:
        ans*=my_pow(P[k])
        ans%=mod
for v in M.values():
    ans*=my_pow(v)
    ans%=mod
ans=(ans-1+my_pow(c)-1)%mod
print(ans)

Submission Info

Submission Time
Task E - ∙ (Bullet)
User bis
Language PyPy3 (7.3.0)
Score 0
Code Size 1030 Byte
Status WA
Exec Time 559 ms
Memory 120652 KB

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 15
WA × 8
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
Subtask1 sample_01.txt, sample_02.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt
Case Name Status Exec Time Memory
sample_01.txt AC 86 ms 64912 KB
sample_02.txt AC 59 ms 65148 KB
sub1_01.txt AC 546 ms 120652 KB
sub1_02.txt AC 60 ms 64652 KB
sub1_03.txt AC 60 ms 65028 KB
sub1_04.txt AC 59 ms 64984 KB
sub1_05.txt AC 60 ms 65168 KB
sub1_06.txt AC 62 ms 65008 KB
sub1_07.txt AC 61 ms 64984 KB
sub1_08.txt AC 60 ms 64968 KB
sub1_09.txt AC 60 ms 64944 KB
sub1_10.txt AC 60 ms 64972 KB
sub1_11.txt WA 252 ms 72032 KB
sub1_12.txt WA 430 ms 76264 KB
sub1_13.txt WA 559 ms 79960 KB
sub1_14.txt WA 375 ms 70652 KB
sub1_15.txt WA 158 ms 69816 KB
sub1_16.txt WA 371 ms 74260 KB
sub1_17.txt WA 250 ms 69904 KB
sub1_18.txt AC 351 ms 69824 KB
sub1_19.txt AC 174 ms 75844 KB
sub1_20.txt AC 301 ms 94688 KB
sub1_21.txt WA 262 ms 69516 KB