Determining whether a relation is the "union" of two other relations
The following should suffice:

for each (x,y) in P:
    if (x,y) in Q, print "nope" and quit
for each (x,y) in Q:
    if (x,y) in P, print "nope" and quit
count the number of pairs in P and Q.
if this sums to |S|^2, output "yup, otherwise output "nope".


You could use any method.  For instance, you could compute $P \cup Q$ directly, then compute $P \cap Q$ directly (say, using mergesort-like methods), and check that each has the desired value.

All of these will have essentially the same asymptotic running time.