#K48222. Valid Transaction Verification
Valid Transaction Verification
Valid Transaction Verification
Problem Description:
You are given a list of transaction operations, where each operation is represented by a list of integers. A transaction is considered valid if and only if it contains exactly one non-zero integer, while all the other integers are zero. Your task is to determine whether all the transactions satisfy this rule. If every transaction is valid, print Valid
; otherwise, print Invalid
.
Input Constraints:
- The first line of input contains an integer N — the number of transactions.
- Each of the next N lines contains a space-separated list of integers representing a single transaction operation.
Example:
If the input is:
4
5 0 0
0 3 0
-2 0 0
0 0 4
Then the output should be:
Valid
inputFormat
The input is read from standard input (stdin) and has the following format:
• The first line contains an integer N, representing the number of transactions.
• Each of the following N lines contains a space-separated list of integers which represents a single transaction.
outputFormat
The output is written to standard output (stdout) and should be a single line containing either Valid
if every transaction is valid according to the rule, or Invalid
if at least one transaction fails to meet the condition.## sample
4
5 0 0
0 3 0
-2 0 0
0 0 4
Valid