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

32834번 - Pair Sorting 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB1761198771.311%

문제

There are $n$ bins arranged in a row and 2ドルn$ balls on the ground. The balls are numbered from 1ドル$ to $n$ and there are exactly two balls numbered $i,ドル for each $i,ドル 1ドル ≤ i ≤ n$. Also, for 1ドル ≤ i ≤ n,ドル the $i$-th bin is denoted by $B_i$ and each bin $B_i$ can contain at most two balls. Initially, the bin $B_i$ contains both of ball $n + 1 - i$’s, for 1ドル ≤ i ≤ n$. See the Figure F.1 below for the initial configuration of bins.

Figure F.1. The initial configuration of bins

You can swap two balls only from adjacent bins, which implies one swap operation. Note the bin is not a stack and for adjacent bins $B_i$ and $B_{i+1},ドル you can swap the one of two balls in $B_i$ and the one in $B_{i+1}$. See the Figure F.2 below. The figure represents two swap operations.

Figure F.2. The swap operations between adjacent bins

Through these swap operations, you should sort the balls. As a result of the sorting, the bin $B_i$ must contain the both of ball $i$’s, for 1ドル ≤ i ≤ n$. In particular, the total number of swap operations should be no more than $Bound,ドル when $Bound$ is given as a function of $n,ドル especially, $Bound = 0.7n^2$.

Given $n$ bins and 2ドルn$ balls, write a program to find a sorting method of balls such that the total number of swap operations is no more than $Bound = 0.7n^2$.

입력

Your program is to read from standard input. The input consists of exactly one line. The line contains an integer $n$ (3ドル ≤ n ≤ 100$), representing that there are $n$ bins and 2ドルn$ balls.

출력

Your program is to write to standard output. Let $S$ be the total number of swap operations in your sorting method for the input. Print exactly $S + 1$ lines. The first line contains $S$. Each of the following $S$ lines contains three integers $j,ドル $a,ドル and $b,ドル representing one swap operation between the ball $a$ in the bin $B_j$ and the ball $b$ in $B_{j+1},ドル where 1ドル ≤ j ≤ n - 1$ and 1ドル ≤ a, b ≤ n$. The swap operations in your sorting method should be printed in order, one per line. The number $S$ must satisfy that $S ≤ 0.7n^2$.

제한

예제 입력 1

3

예제 출력 1

6
1 3 2
2 3 1
1 2 1
1 3 2
2 3 1
1 2 1

예제 입력 2

3

예제 출력 2

5
1 3 2
2 3 1
1 3 1
2 3 1
1 2 1

힌트

출처

ICPC > Regionals > Asia Pacific > Korea > 2024 ICPC Asia Seoul Regional F번

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

출처

대학교 대회

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

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