2018 Beijing University of Information Science and Technology 10th Program Design Competition and ACM Selection Competition to play basketball

Link: https://www.nowcoder.com/acm/contest/118/D
Source: Niuke.com

Topic description


1, 2, 3 are playing basketball, but it's always unfair to play two against one, so they decided to go one-on-one, the other person watching from the side, whoever loses will go down with the one who is watching from the side people exchange. Now give you a sequence of winners (whoever wins each round) and ask if this sequence is legal. (At first 1, 2 heads up, 3 is watching below)

Enter description:

The first number is the number n (1<=n<=100), which represents the size of the input winner sequence, and the next n lines describe the winner sequence. Line i contains a positive integer a[i], (1<=a[i]<=3), which means a[i] wins the game

Output description:

output YES if the winner sequence is valid, otherwise NO

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325345367&siteId=291194637