#K74622. Binary String Permutation Processing

    ID: 34239 Type: Default 1000ms 256MiB

Binary String Permutation Processing

Binary String Permutation Processing

You are given an integer Q and Q binary strings. For each binary string S, your task is to determine if it can be processed by the machine.

The machine can process a binary string if and only if the string is a permutation of some binary string that the machine can process. In this problem, a binary string is considered processable if it consists solely of the characters 0 and 1. In other words, the string S is processable if it satisfies:

[ S \in {0,1}^n, \quad n \ge 1 ]

For each input binary string, output YES if the string is processable; otherwise, output NO. Note that in the scope of this problem, all inputs are guaranteed to be valid binary strings, so the expected output will always be YES for each test case.

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

  • The first line contains a single integer Q representing the number of binary strings to process.
  • This is followed by Q lines, each containing a binary string S composed exclusively of the characters '0' and '1'.

outputFormat

For each binary string, output a single line to standard output (stdout) containing either YES if the binary string is processable by the machine, or NO otherwise. In this problem, a binary string is processable if it only consists of the characters '0' and '1', i.e., if it satisfies

[ S \in {0,1}^n, \quad n \ge 1 ]

Since every input string meets this condition, the expected output for each string is YES.## sample

3
101
1001
1110
YES

YES YES

</p>