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

33360번 - Bishops 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB222100.000%

문제

A chess bishop attacks every square that shares a diagonal with it.

Place the maximum number of bishops on an $n \times m$ chessboard in such a way that none of them attack each other.

입력

The first line contains two integers $n$ and $m$: the dimensions of the chessboard (1ドル \leq n, m \leq 10^5 + 1$).

출력

On the first line, print an integer $k$: the maximum possible number of bishops on an $n \times m$ chessboard such that they don't attack each other. On each of the next $k$ lines, print two integers: the coordinates of bishops. The first coordinate should be in the range $[1, n],ドル and the second in the range $[1, m]$. If there are several possible answers, print any one of them.

제한

예제 입력 1

2 5

예제 출력 1

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

예제 입력 2

5 5

예제 출력 2

8
1 1
1 2
5 4
1 3
5 3
1 4
5 2
1 5

힌트

출처

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

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

출처

대학교 대회

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

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