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

26178번 - ETA 스페셜 저지다국어

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

문제

You want to design a level for a computer game. The level can be described as a connected undirected graph with vertices numbered from 1ドル$ to $n$. In the game, the player's character is dropped at one of the $n$ vertices uniformly at random and their goal is to reach the exit located at vertex 1ドル$ as quickly as possible. Traversing an edge takes exactly 1ドル$ second.

Figure E.1: Illustration of Sample Output 3, a level where the average optimal time to reach vertex 1ドル$ is $\frac{7}{4}$.

The difficulty of the level is determined by the average optimal time to reach the exit. Given a target value for this average optimal time, construct a level so that this target value is reached. See Figure E.1 for an example.

입력

The input consists of:

  • One line with two coprime integers $a$ and $b$ (1ドル \le a,b \le 1000$) separated by a '/', giving the desired average optimal time to reach the exit as the fraction $\frac{a}{b}$.

출력

If no connected graph with the average optimal time $\frac{a}{b}$ to reach vertex 1ドル$ exists, output "impossible". Otherwise, output one such graph in the following format:

  • Two integers $n$ and $m$ (1ドル \le n, m \le 10^6$), the number of vertices and the number of edges.
  • $m$ pairs of integers $u$ and $v$ (1ドル \le u,v \le n$), indicating an edge between vertices $u$ and $v$.

The graph may include self loops and parallel edges. You are given that if there exists a valid graph, then there also exists one with 1ドル \le n, m \le 10^6$.

If there are multiple valid solutions, you may output any one of them.

제한

예제 입력 1

1/2

예제 출력 1

2 1
1 2

예제 입력 2

1/3

예제 출력 2

impossible

예제 입력 3

7/4

예제 출력 3

8 12
1 2
1 3
2 3
2 4
3 5
3 6
4 5
5 6
4 7
5 7
4 8
6 8

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2022 E번

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

출처

대학교 대회

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

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