Binary associativity

3.6

51 votes
Basic Programming, Basics of Implementation, Easy, Implementation
Problem

A binary operation  on a set S is called associative if it satisfies the associative law: (xy)z=x(yz) for all x, yz in S.

For the binary set S={0,1} and a particular binary operator , you are given its truth table. Determine if the operation is associative.

a b ab
0 0 c0
0 1 c1
1 0 c2
1 1 c3

Input format

  • First line: A single integer T denoting the number of test cases

  • For each test case:

    • First line: Four space-separated integers c0,c1,c2,c3

Output format

For each test case, print 'Yes' (without quotes) in a new line if the binary operation is associative in nature. Otherwise, print 'No' (without quotes).

Constraints

1T8

c0,c1,c2,c3{0,1}

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The given operation is the binary xor. It can be easily proved that it is associative.

Editor Image

?