CF761B.Dasha and friends
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:
The track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track.
Her friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively.
Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7].
There are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks.
Write the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above.
在达莎居住的国家,环形跑道上的跨栏跑非常流行,因此她在上学途中看到如下场景也就不足为奇了:
跑道是一个长度为 L 的圆,在其上若干互不相同的点处设有 n 个跨栏。运动员始终以俯视视角下的逆时针方向绕跑道奔跑。所有跨栏沿跑道彼此之间的距离均为整数。
她的朋友——鹦鹉凯法(Kefa)和猎豹萨沙(Sasha)参加了比赛,每人各跑了一圈。两位朋友均从跑道上某个整数位置出发。两人各自记录了从自己的起点沿跑道(逆时针方向)到每个跨栏的距离。因此,每人各记录了 n 个整数,这些整数严格递增,且每个数均在 0 到 L−1(含端点)之间。
考虑一个例子:设 L=8,蓝色点为跨栏,绿色点为凯法的起点(A)和萨沙的起点(B)。则凯法记录的序列为 [2,4,6],而萨沙记录的序列为 [1,5,7]。
该国存在多条跑道,所有跑道长度相同、跨栏数量也相同,但不同跑道上跨栏的位置可能不同。现在达莎想知道:凯法与萨沙是否可能在同一条跑道上参赛,还是他们实际上分别在不同的跑道上参赛。
请编写一个程序,判断凯法与萨沙所跑的跑道是否一致(即:二者仅起点不同,其余跨栏位置完全相同)。注意:他们始终按同一方向——俯视视角下的逆时针方向——奔跑。
输入格式
The first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length.
The second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.
The second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.
第一行包含两个整数 n 和 L(1≤n≤50,n≤L≤100)—— 分别表示赛道上障碍物的数量以及赛道的长度。
第二行包含 n 个互不相同的、按升序排列的整数——表示从基法的起点到每个障碍物的距离,顺序为障碍物出现的顺序。所有整数均在 0 到 L−1(含端点)范围内。
第三行包含 n 个互不相同的、按升序排列的整数——表示从萨沙的起点到每个障碍物的距离,顺序为萨沙跨越该障碍物的顺序。所有整数均在 0 到 L−1(含端点)范围内。
输出格式
Print "YES" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print "NO" (without quotes).
如果基法和萨沙跑的是相同的赛道(即:若他们从赛道上的同一点起跑,则所有障碍物的位置均完全重合),则输出 "YES"(不带引号);否则输出 "NO"(不带引号)。
输入输出样例
输入#1
3 8 2 4 6 1 5 7
输出#1
YES
输入#2
4 9 2 3 5 8 0 1 3 6
输出#2
YES
输入#3
2 4 1 3 1 2
输出#3
NO
说明/提示
The first test is analyzed in the statement.
第一个测试用例在题目描述中已进行分析。
输入解题思路,AI测评打分。不知道怎么写?