Public Judge

pjudge

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100

#21866. 赤橙黄绿

Statistics

题目描述

给定一个 $N \times M$ 的棋盘,初始时,棋盘上所有的位置都是空的。

不是小青鱼 想要进行若干次操作,每次操作形如:

  1. 选择一个空的格子 $(i, j)$。
  2. 设 $x$ 为此时在 $(i, j)$ 所在的行和列中均未出现过的最小的正整数。
  3. 将数字 $x$ 填入格子 $(i, j)$。

不是小青鱼 希望你能进行若干次操作,使得在最后一次操作完成时,数字 $X$ 第一次被填入某个格子中。然而,不是小青鱼 希望你执行操作的次数 $Q$ 恰好位于区间 $[L, R]$ 中。不是小青鱼 想要你构造一组可能的条件,或者反馈不存在对应的方案。

输入格式

输入只有一行,包含五个整数 $N,M,X,L,R$。

输出格式

对于每组数据,如果不存在对应的方案,输出一行一个整数 -1

否则,输出的第一行包含一个整数 $Q$($L \le Q \le R$),表示你的操作次数。

接下来 $Q$ 行,每行两个整数 $(i, j)$,按照顺序描述每个操作。

样例数据

样例输入

7 10 7 10 100

样例输出

43
1 1
2 2
3 3
4 4
5 5
6 6
7 7
1 2
2 3
3 4
4 5
5 6
6 7
7 1
1 3
2 4
3 5
4 6
5 7
6 1
7 2
1 4
2 5
3 6
4 7
5 1
6 2
7 3
1 5
2 6
3 7
4 1
5 2
6 3
7 4
1 6
2 7
3 1
4 2
5 3
6 4
7 5
1 7

子任务

对于所有数据,$1 \leq N,M \leq 500$,$1 \leq L \leq R \leq 10^9$,$1 \leq X \leq 10^9$

子任务一(6 分)

$N \leq 20$

$M \leq 20$

子任务二(6 分)

$N \leq 2$

子任务三(14 分)

$N \leq 5$

子任务四(5 分)

$L = 1, R=10^9$

子任务五(23 分)

$L = 1$

子任务六(25 分)

$N \ne M$

子任务七(21 分)

没有额外的限制。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.