def cup(x, y):
if not x or not y:
return x + y
return f'({x}) or ({y})'
def cap(x, y):
if not x or not y:
return ''
return f'({x}) and ({y})'
def complement(x):
if not x:
return 'True'
return f'not ({x})'
placeholder = '#'
def main():
n, m, q = map(int, input().split())
A_nm = [f'{placeholder}%{j}==0' for j in range(1, n + 1)]
for j in range(m):
input_ = input()
if input_[0] == '3':
_, i = map(int, input_.split())
A_nm.append(complement(A_nm[i-1]))
continue
index, x, y = map(int, input_.split())
app = cup(A_nm[x-1], A_nm[y-1]) if index == 1 else cap(A_nm[x-1], A_nm[y-1])
A_nm.append(app)
# print('\n')
for _ in range(q):
x, v = input().split()
x = int(x)
# print(A_nm[x-1])
# print(x, v)
if eval(A_nm[x-1].replace(placeholder, v)):
print("TAK")
else:
print("NIE")
if __name__ == "__main__":
main()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | def cup(x, y): if not x or not y: return x + y return f'({x}) or ({y})' def cap(x, y): if not x or not y: return '' return f'({x}) and ({y})' def complement(x): if not x: return 'True' return f'not ({x})' placeholder = '#' def main(): n, m, q = map(int, input().split()) A_nm = [f'{placeholder}%{j}==0' for j in range(1, n + 1)] for j in range(m): input_ = input() if input_[0] == '3': _, i = map(int, input_.split()) A_nm.append(complement(A_nm[i-1])) continue index, x, y = map(int, input_.split()) app = cup(A_nm[x-1], A_nm[y-1]) if index == 1 else cap(A_nm[x-1], A_nm[y-1]) A_nm.append(app) # print('\n') for _ in range(q): x, v = input().split() x = int(x) # print(A_nm[x-1]) # print(x, v) if eval(A_nm[x-1].replace(placeholder, v)): print("TAK") else: print("NIE") if __name__ == "__main__": main() |
English