포럼
문제 ICPC00211

K. Kebab Pizza

설명

Alice loves pizza and plans to throw a pizza party for her birthday, where she will make one big, round pizza for all her guests. She knows that her friends are a bit special when it comes to pizza: Julie does not want any vegetables but loves kebab meat on her pizza. Katy would never eat pizza with cheese on top. Alice herself is a huge fan of pineapple on pizza, while Mickey absolutely hates it. Instead, he wants to put spaghetti on it, which everybody else finds weird. The list goes on and on. Briefly put, it is absolutely impossible to accommodate everybody.

As a compromise, Alice decides to let each person choose two toppings for their pizza slice in advance. Each person will be happy if their slice has exactly their two chosen toppings and none of the others. Note that a person may choose the same topping twice, in which case they just get twice the amount of that topping.

On the day of her party, Alice discovers that the rolled out pizza dough takes up so much space on her kitchen counter that she can only prepare one kind of topping at a time. To optimise the workflow and to make sure that the pizza is ready in time for her party, she wants to take out each chosen kind of topping only once and then add it on a consecutive range of pizza slices. Note that the whole pizza forms a consecutive range of pizza slices in a circular fashion. Determine whether it is possible to prepare the pizza in this way while satisfying all the chosen topping combinations. See Figure for an example.

제약
입력 형식

The input consists of:
- One line with two integers \(n\) and \(k\) (\(3\leq n, k \leq 10^5\)), the number of pizza slices and the number of possible toppings which are numbered from \(1\) to \(k\).
- \(n\) lines, each with two integers \(a\) and \(b\) (\(1\leq a, b \leq k\)), describing the toppings chosen by the \(i\)th person.

출력 형식

Output "possible" if it is possible for Alice to select a consecutive range of pizza slices for each chosen topping such that the resulting pizza can be split into \(n\) suitable slices. Otherwise, output "impossible".

예제 1
입력
7 6
2 2
3 6
1 1
1 5
4 5
6 6
6 5
출력
possible
예제 2
입력
5 5
1 3
1 5
2 3
2 5
3 4
출력
possible
예제 3
입력
6 7
1 2
2 3
3 4
4 5
3 6
6 7
출력
impossible
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NWERC 2022

평가 및 의견

K. Kebab Pizza

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

K. Kebab Pizza

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8