Logo
(追記) (追記ここまで)

26013번 - Chaotic Construction 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB89615481.818%

문제

The city Gircle has only one street, and that street is cyclic. This was very convenient in times when people didn't carry a device with compass, GPS and detailed maps around in their pockets, because you only have to walk in one direction and will certainly arrive at your destination. Since Gircle's founding a lot of time has passed. Civil engineers now know a lot more about road network design and most people have immediate access to reliable and accurate navigation systems. However, the passage of time also affected the old street surface and more and more cracks and potholes appeared.

The local government has finally decided to improve the situation, but preserving the city's historic appeal and building new streets are unfortunately mutually exclusive. Because tourism is vital for Gircle's economy, the government's only viable option for improving the situation is to renovate segments of the street when necessary. Gircle's street is very narrow, so a construction site at a street segment makes it impossible for citizens to pass that segment or even leave or enter it.

As a member of the Gircle Construction and Planning Commission (GCPC), you always know when one of the $n$ street segments is closed or reopened. Naturally, the citizens expect you to tell them whether the trips they want to do are currently possible.

Figure C.1: Depiction of the query "? 9 7" in the sample input.

입력

The input consists of:

  • One line with two integers $n$ (2ドル \leq n \leq 10^5$) and $q$ (1ドル \leq q \leq 10^5$), the number of street segments and the number of events. No street segment is initially closed.
  • $q$ lines, each describing an event. Each event is described in one of the following ways:
    • "- a": Segment $a$ (1ドル \leq a \leq n$) is closed. It is guaranteed that segment $a$ was open before.
    • "+ a": Segment $a$ (1ドル \leq a \leq n$) is reopened. It is guaranteed that segment $a$ was closed before.
    • "? a b": A person asks you if it is possible to go from segment $a$ to segment $b$ (1ドル \leq a, b \leq n \text{ and } a\neq b$).

출력

For each event of the form "? a b", print one line containing the word "possible", if it is possible to move from segment $a$ to segment $b,ドル or "impossible" otherwise. If $a$ or $b$ are currently closed, the answer is "impossible".

제한

예제 입력 1

10 12
? 1 5
- 2
- 8
? 9 2
? 9 8
? 9 7
? 6 7
? 3 7
? 1 9
? 9 1
+ 8
? 10 3

예제 출력 1

possible
impossible
impossible
impossible
possible
possible
possible
possible
possible

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2022 C번

  • 문제를 만든 사람: Julian Baldus
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /