CF30B.Codeforces World Finals

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

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.

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.

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.

国王科帕经常听说 Codeforces 网站——这个正迅速在人类最杰出头脑中日益流行起来的平台,他们用它进行训练和竞赛。最近,科帕意识到:若想征服世界,他必须举办一场“世界 Codeforces 总决赛”。他希望借此使这些最杰出的头脑成为自己的下属,从而完成征服世界中最艰难的部分。

Codeforces 世界总决赛 20YY 年的决赛日定于 DD.MM.YY,其中 DD 表示决赛日的日期(日),MM 表示月份(月),YY 表示年份的后两位数字(年)。鲍勃很幸运,成为来自贝尔兰的第一位决赛选手。但这里存在一个问题:根据比赛规则,所有参赛者在决赛当日必须年满 18 周岁。鲍勃出生于 BD.BM.BY。该出生日期已登记在他的护照上,而他早已将护照复印件寄给了赛事组织方。然而鲍勃得知,在不同国家,日期的书写格式各不相同。例如,在美国,日期按“月/日/年”的顺序书写。鲍勃不禁疑惑:能否重新排列他出生日期中的三个数字(即 BD, BM, BY),使得他在 DD.MM.YY 这一天至少已满 18 周岁?他总可以辩称,在自己的祖国,日期的书写方式是不同的。请帮助他。

根据另一条奇怪的规定:合格的参赛者必须与决赛日期处于同一世纪。若决赛当天恰好是参赛者 18 周岁生日,则允许其参赛。

由于本题中决赛年份仅考虑 2001 至 2099 年之间的年份,请采用如下闰年判定规则:若年份能被 4 整除,则为闰年。

输入格式

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].

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.

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

有可能根据护照,Bob 的出生日期晚于决赛日期。此时,他仍可调整日期中各位数字的顺序。

输出格式

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.

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.

如果可以重新排列出生日期中的数字,使得鲍勃在 DD.MM.YY 这一天至少满 18 周岁,则输出 YES;否则输出 NO。

每个数字均恰好包含两位数字,分别表示日期中的日、月或年。注意:只允许重新排列这些数字本身,而不允许重新排列各位数字。

输入输出样例

  • 输入#1

    01.01.98
    01.01.80

    输出#1

    YES
  • 输入#2

    20.10.20
    10.02.30

    输出#2

    NO
  • 输入#3

    28.02.74
    28.02.64

    输出#3

    NO

输入解题思路,AI测评打分。不知道怎么写?

首页