DMOPC '18 Contest 6 P0 - SQL Queries

View as PDF

Submit solution


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

Author:
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 ith SQL query requires the jth query to have been debugged, debugging the jth query might require the kth 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 ith integer will be 0 if the ith query can be debugged straight away, otherwise it will be a positive integer aii, meaning that query ai must be debugged before query i.

Output Specification

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

Sample Input

Copy
3 1 2

Sample Output

Copy
NO

Explanation for Sample Output

We have the loop 1321, and thus none of them can be debugged.


Comments

There are no comments at the moment.