inp = input() inp = inp.split() n = int(inp[0]) q = int(inp[1]) komp = ["0"]*n result = "" chars_dict = {"00": "??","01": "11", "0?": "1?", "10": "11","11": "11", "1?": "11", "?0": "?1","?1": "11", "??": "??" } for i in range(q): inp = input() inp = inp.split() c = inp[0] a = int(inp[1]) if c=="-": komp[a-1]="0" elif c=="?": result+=komp[a-1] else: b = int(inp[2]) ca=komp[a-1] cb=komp[b-1] if a==b: komp[a-1]="1" else: cc = chars_dict[ca+cb] komp[a-1]=cc[0] komp[b-1]=cc[1] print(result)
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 | inp = input() inp = inp.split() n = int(inp[0]) q = int(inp[1]) komp = ["0"]*n result = "" chars_dict = {"00": "??","01": "11", "0?": "1?", "10": "11","11": "11", "1?": "11", "?0": "?1","?1": "11", "??": "??" } for i in range(q): inp = input() inp = inp.split() c = inp[0] a = int(inp[1]) if c=="-": komp[a-1]="0" elif c=="?": result+=komp[a-1] else: b = int(inp[2]) ca=komp[a-1] cb=komp[b-1] if a==b: komp[a-1]="1" else: cc = chars_dict[ca+cb] komp[a-1]=cc[0] komp[b-1]=cc[1] print(result) |