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

33364번 - Very Sparse Table 다국어인터랙티브

시간 제한메모리 제한제출정답맞힌 사람정답 비율
30 초 (추가 시간 없음) 2048 MB162212.500%

문제

This is an interactive problem.

You are given a directed graph $G$ on vertices numbered 0ドル$ to $n$. Initially, $G$ contains exactly $n$ edges of the form $v \to v + 1$. Your task is to add some edges to this graph in such a way that for every two vertices $v, u$ ($v < u$) there exists a directed path from $v$ to $u$ consisting of at most three edges. There are also two additional requirements you must meet:

  1. You can add an edge $a \to c$ if and only if there exists such $b$ that edges $a \to b$ and $b \to c$ are already present in $G$.
  2. You can add at most 6ドル \cdot n$ edges in total.

인터랙션 프로토콜

The interaction starts with the interactor printing the only integer $n$ (0ドル \leq n \leq 2^{16}$) on a single line. After that, your program should output $k$ (0ドル \leq k \leq 6 \cdot n$): the number of edges you want to add to the graph. The next $k$ lines should contain descriptions of the added edges in the order of their addition. Each edge should be described by three integers $a, b, c,ドル meaning that you add the edge $a \to c,ドル and that edges $a \to b$ and $b \to c$ are already present in $G$.

Do not forget to flush the output buffer after this (you can use cout << flush; in C++), otherwise, the solution will get "Idleness Limit Exceeded".

Then, the interactor prints the number of queries $q$ (0ドル \leq q \leq 2 \cdot 10^5$) and $q$ queries on the next $q$ lines. Each query is described by two integers $\ell, r$ (0ドル \leq \ell < r \leq n$) for which your program should output a line containing a path in $G$ of length at most three that starts in vertex $\ell$ and finishes in vertex $r$. The path should be printed as a sequence of all vertices it visits (including both endpoints) separated by spaces.

To get the next query, the solution must print the answer to the previous query, end the line with a newline and flush the output buffer. The queries depend on the edges you printed.

In the example below, there are no actual empty lines in input and output: they are only added to visually align the inputs and the respective outputs.

입력

출력

제한

예제 입력 1

9
3
1 8
2 4
0 5

예제 출력 1

7
1 2 3
0 1 3
6 7 8
6 8 9
3 4 5
4 5 6
3 5 6
1 3 6 8
2 3 4
0 1 3 5

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2023 > Day 4: SPb SU Contest, LVII SPb SU Championship H번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

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

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