This is the question i am trying to solve: https://open.kattis.com/problems/abinitio

This is my logic. I will represent the graph using a 2d adjacency matrix. adj[i][x] represents if there is a directed connection from i to x. And I also hold two booleans values. "transposed", and "complmented". So this is how I will handle the queries. My logic is that transposing or complementing the graph twice (no matter the updates in between) will always be the same as not complementing or transposing at all. So when I want to detect whether or not there is an edge between two nodes, u, v. If the graph is transposed, I will check adj[v][u] == complemented^1. Otherwise I will check adj[u][v] = complemented^1. (If complemented is 1, i am looking for 0 and vice versa).

So this is the code I produced: https://pastebin.com/Khp01P70

However, I get WA on testcase 4. Can someone please help me debug this? Thanks in advance.