PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: Tejas Pandey
Testers: Utkarsh Gupta, Jatin Garg
Editorialist: Nishank Suresh
DIFFICULTY:
365
PREREQUISITES:
None
PROBLEM:
Given the decisions of four referees as to whether a ball was in or out, decide whether the ball was indeed in or not. It is considered to be in if and only if all 4 referees say that it is in.
EXPLANATION
Simply check if all 4 numbers given in the input are 0 or not. If they are, print “In”, otherwise print “Out”.
This check can be done in several ways, for example:
- Apply an if condition to each input integer
- Or, find the sum of all 4 numbers and check if this is zero
TIME COMPLEXITY
\mathcal{O}(1) per test case.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
print('In' if sum(map(int, input().split())) == 0 else 'Out')