All Tracks Basic Programming Implementation Basics of Implementation Problem

Binary associativity
Tag(s):

Basic Programming, Basics of Implementation, Implementation, Very-Easy

Problem
Editorial
Analytics

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 \}\)

 

SAMPLE INPUT
1
0 1 1 0
SAMPLE OUTPUT
Yes
Explanation

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

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), TypeScript, Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

December Easy' 18

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?