Codeforces Beta Round 30(Codeforces 格式)
B
Codeforces 世界总决赛
Codeforces World Finals
Codeforces
1700
原题
← AC →

Codeforces 世界总决赛AI (CI翻译)

The king Copa often has been reported about the Codeforces site, which is rapidly getting more and more popular among the brightest minds of the humanity, who are using it for training and competing. Recently Copa understood that to conquer the world he needs to organize the world Codeforces tournament. He hopes that after it the brightest minds will become his subordinates, and the toughest part of conquering the world will be completed.

国王 Copa 经常听说 Codeforces 网站。这个网站正迅速受到越来越多杰出人才的欢迎,他们利用它进行训练和比赛。最近,Copa 意识到,要征服世界,他需要举办 Codeforces 世界锦标赛。他希望比赛结束后,这些杰出人才会成为他的部下,而征服世界最艰难的部分也将就此完成。AI (CI翻译)

The final round of the Codeforces World Finals 20YY is scheduled for $*DD*$.$*MM*$.$*YY*$, where $*DD*$ is the day of the round, $*MM*$ is the month and $*YY*$ are the last two digits of the year. Bob is lucky to be the first finalist form Berland. But there is one problem: according to the rules of the competition, all participants must be at least 18 years old at the moment of the finals. Bob was born on $*BD*$.$*BM*$.$*BY*$. This date is recorded in his passport, the copy of which he has already mailed to the organizers. But Bob learned that in different countries the way, in which the dates are written, differs. For example, in the US the month is written first, then the day and finally the year. Bob wonders if it is possible to rearrange the numbers in his date of birth so that he will be at least 18 years old on the day $*DD*$.$*MM*$.$*YY*$. He can always tell that in his motherland dates are written differently. Help him.

Codeforces 世界总决赛 20YY 定于 $*DD*$.$*MM*$.$*YY*$ 举行,其中 $*DD*$ 是比赛日期,$*MM*$ 是月份,$*YY*$ 是年份的后两位。Bob 很幸运,成为了第一位来自 Berland 的决赛选手。但有一个问题:根据比赛规则,所有参赛者在决赛当天都必须年满 18 岁。Bob 出生于 $*BD*$.$*BM*$.$*BY*$。这个日期记录在他的护照上,他已经把护照复印件寄给了主办方。但 Bob 得知,不同国家书写日期的方式各不相同。例如,在美国,日期先写月份,再写日期,最后写年份。Bob 想知道,能否重新排列他的出生日期中的数字,使他在 $*DD*$.$*MM*$.$*YY*$ 当天至少年满 18 岁。他总可以声称自己的祖国采用不同的日期书写方式。请帮助他。AI (CI翻译)

According to another strange rule, eligible participant must be born in the same century as the date of the finals. If the day of the finals is participant's 18-th birthday, he is allowed to participate.

还有一条奇怪的规则:符合资格的参赛者必须与决赛日期处于同一个世纪。如果决赛当天正好是参赛者的 18 岁生日,他也可以参赛。AI (CI翻译)

As we are considering only the years from $2001$ to $2099$ for the year of the finals, use the following rule: the year is leap if it's number is divisible by four.

由于我们只考虑 $2001$ 到 $2099$ 年的决赛日期,因此采用以下规则:年份能被 4 整除时就是闰年。AI (CI翻译)

Input

输入格式

AI (CI翻译)

The first line contains the date $*DD*$.$*MM*$.$*YY*$, the second line contains the date $*BD*$.$*BM*$.$*BY*$. It is guaranteed that both dates are correct, and $*YY*$ and $*BY*$ are always in $[01;99]$.

第一行包含日期 $*DD*$.$*MM*$.$*YY*$,第二行包含日期 $*BD*$.$*BM*$.$*BY*$。保证两个日期均合法,且 $*YY*$ 和 $*BY*$ 始终在 $[01;99]$ 范围内。AI (CI翻译)

It could be that by passport Bob was born after the finals. In this case, he can still change the order of numbers in date.

Bob 护照上记录的出生日期可能晚于决赛日期。在这种情况下,他仍然可以更改日期中各数字的顺序。AI (CI翻译)

Output

输出格式

AI (CI翻译)

If it is possible to rearrange the numbers in the date of birth so that Bob will be at least 18 years old on the $*DD*$.$*MM*$.$*YY*$, output YES. In the other case, output NO.

如果可以重新排列出生日期中的数字,使 Bob 在 $*DD*$.$*MM*$.$*YY*$ 当天至少年满 18 岁,则输出 YES;否则输出 NO。AI (CI翻译)

Each number contains exactly two digits and stands for day, month or year in a date. Note that it is permitted to rearrange only numbers, not digits.

每个数字恰好包含两位,分别表示日期中的日、月或年。注意,只允许重新排列这些数字,不允许重新排列数字中的各位。AI (CI翻译)

样例

Input #1
01.01.98
01.01.80
Output #1
YES
InputCopy OutputCopy
Input #2
20.10.20
10.02.30
Output #2
NO
InputCopy OutputCopy
Input #3
28.02.74
28.02.64
Output #3
NO
InputCopy OutputCopy
题目信息
题号
30B
时间限制
2 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。