Pyramids
시간 제한1초메모리 제한1024 MB
두 배열이 주어질 때, 한 부분 배열의 돌을 인접한 위치로 하나씩 옮겨 같은 길이의 다른 부분 배열로 만들 수 있는지 묻는 질의에 답한다.
문제
Everyone knows that Pharaoh Khufu was a great ruler, but many are unaware that he was also a fashion enthusiast. Back in the day, he had pyramids numbered from to , with pyramid () consisting of stones. He also had the latest catalogue of the most fashionable pyramids of the year. The catalogue consists of pyramids numbered from to , with pyramid () consisting of stones.
For any and , such that , we define a range of pyramids to be a sequence . We also define a range of pyramids analogously.
Every day, Khufu would browse the catalogue and choose two ranges of pyramids and where (the values of , , and may be different every day). After that, he would like to know whether it's possible to transform his range to become equal to the catalogue's range . Transforming a range consists of performing the following step an arbitrary number of times: take one stone from a pyramid within the range and move it to an adjacent pyramid within the range.
Your task is to answer multiple questions of the following form. Given four integers , , , and , determine whether it is possible to transform into . Note that the number of stones in each pyramid never actually changes, Khufu only wonders if one range could be transformed into the other one.
제한
In each call to can_transform:
예제
이 문제는 공개된 예제가 없습니다.