DMOPC '18 Contest 6 P0 - SQL Queries

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem type

Roger is trying to debug three SQL queries. Sadly, he is not very good at SQL, and ends up in a bit of a situation. For some number of the queries, he must first debug another of the three queries. So it is possible that debugging the i^\text{th} SQL query requires the j^\text{th} query to have been debugged, debugging the j^\text{th} query might require the k^\text{th} query to be debugged first, and so on.

Given these constraints, can you tell Roger if it is possible for him to debug all three of his queries?

Input Specification

The first and only line of input will contain 3 integers. The i^\text{th} integer will be 0 if the i^\text{th} query can be debugged straight away, otherwise it will be a positive integer a_i \ne i, meaning that query a_i must be debugged before query i.

Output Specification

Output YES if all the queries can be debugged, and NO otherwise.

Sample Input

3 1 2

Sample Output


Explanation for Sample Output

We have the loop 1 \to 3 \to 2 \to 1, and thus none of them can be debugged.


There are no comments at the moment.