Binary associativity
Practice
3.6 (51 votes)
Basic programming
Basics of implementation
Easy
Implementation
Problem
33% Success 8831 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code
A binary operation \(*\) on a set \(S\) is called associative if it satisfies the associative law: \((x * y) * z = x * (y * z)\) for all \(x\), \(y\), \(z\) 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\) | \(a * b\) |
\(0\) | \(0\) | \(c_{0}\) |
\(0\) | \(1\) | \(c_{1}\) |
\(1\) | \(0\) | \(c_{2}\) |
\(1\) | \(1\) | \(c_{3}\) |
Input format
-
First line: A single integer \(T\) denoting the number of test cases
-
For each test case:
-
First line: Four space-separated integers \(c_{0}, c_{1}, c_{2}, c_{3}\)
-
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
\(1 \le T \le 8\)
\(c_0, c_1, c_2, c_3 \in \{ 0, 1 \}\)
Submissions
Please login to view your submissions
Similar Problems
Points:10
258 votes
Tags:
Brute-force searchEasy
Points:10
112 votes
Tags:
Basic ProgrammingBasics of ImplementationImplementation
Points:10
100 votes
Tags:
Easy
Editorial