이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |