제출 #653854

#제출 시각아이디문제언어결과실행 시간메모리
653854beaconmcPlus Minus (BOI17_plusminus)Pypy 3
100 / 100
342 ms40052 KiB
n,m,k = map(int, input().split()) sussies = dict() flagx = True flagy = True for i in range(k): a,b,c = input().split() b = int(b);c=int(c) if b in sussies: if sussies[b] != (c+(a=="-"))%2: flagx = False else: sussies[b] = (c+(a=="-"))%2 if -c in sussies: if sussies[-c] != (b+(a=="-"))%2: flagy = False else: sussies[-c] = (b+(a=="-"))%2 if flagx==flagy==False: print(0) else: x = [0,1] y = [0,1] samex=1 diffx=1 samey=1 diffy=1 ans = 0 if flagx: temp = n for i in sussies: if i > 0: temp -= 1 if sussies[i]%2 != i%2: samex = 0 if sussies[i]%2 == i%2: diffx = 0 ans += pow(2, temp, 1000000007) if flagy: temp = m for i in sussies: if i < 0: temp -= 1 if sussies[i]%2 != i%2: samey = 0 if sussies[i]%2 == i%2: diffy = 0 ans += pow(2, temp, 1000000007) print(ans%1000000007 - (samex==samey==1) - (diffx == diffy==1))
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...