Bob's confusion
Practice
3.4 (5 votes)
Algorithms
Basics of greedy algorithms
Greedy algorithms
Problem
89% Success 475 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given a \(3\times 3\) grid. Each number in the grid is represented by $$C_{ij}$$ where \((i,j)\) denotes the square at the \(i^{th}\) row from the top and \(j^{th}\) column from the left.
Bob gets confused. According to him, there are six integers \(a_1, a_2, a_3, b_1, b_2, b_3\) whose values are fixed and the number written in the square \((i,j)\) is equal to \(a_i + b_j\). You are required to determine whether Bob is correct or not.
Input format
- The first line contains an integer $$T$$ denoting the number of test cases.
- Next three lines contain three space-separated integers $$C_{i1}, C_{i2}$$, and $$C_{i3}$$ denoting the \(i^{th}\) row of grid $$C$$.
Output format
For each test case, print YES if Bob's statement is correct. Otherwise, print NO in a new line.
Constraints
\(1 \le T \le 200000\\ 0 \le C_{ij} \le 1000000000\)
Submissions
Please login to view your submissions
Similar Problems
1.Factors
Points:30
10 votes
Tags:
SortingAlgorithmsBasics of Greedy AlgorithmsGreedy Algorithms
Points:30
70 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsC++Greedy Algorithms
Points:30
6 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsC++Greedy Algorithms
Editorial