当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4671:Backup Plan

Special Judge 特殊评判
题目描述
Makomuno has N servers and M databases. All databases are synchronized among all servers and each database has a ordered list denotes the priority of servers to access. This list is guaranteed to be a valid permutation of all servers.
Every time someone wants to execute queries on a certain database, he will send a request to the first server in the list. If it's dead, he will simply turn to the next one. Otherwise a working copy of the database is found, and this copy is called active.
Now, given N and M, Makomuno wants to find a permutation for each database which could assure that all servers are load-balanced. Moreover, Makomuno hopes the system will be load-balanced even if exactly one server is broken.
Note that if we call the number of active copies on i-th server Ai, then load-balanced means max∣Ai - Aj∣≤1 for any i and j in non broken servers set. We won't consider broken servers in this case.
输入解释
The input contains several test cases, terminated by EOF.
Each test case has one line containing two integer N ( 2≤N≤100) and M ( 1≤M≤100).
输出解释
For each case output M lines, the i-th line contains a permutation of all servers, indicating the expected order. Servers are numbered from 1 to n.
输入样例
5 3
输出样例
2 4 3 1 5
1 5 4 2 3
3 5 2 4 1
提示
In the sample test case, the active copies of these databases are on server 2,1 and 3 in normal state. A = {1,1,1,0,0}
If server 1 or 3 has broken, server 5 will take its work. In case we lost server 2, the second database will use server 4 instead. A = {1,BROKEN,1,1,0}
It's clear that in any case this system is load-balanced according to the plan in sample output. 
来自杭电HDUOJ的附加信息
Recommend zhuyuanchen520

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4671

最后修改于 2020-10-25T23:15:40+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65535/65535K(Java/Others)