CF22C.System Administrator
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Bob got a job as a system administrator in X corporation. His first task was to connect n servers with the help of m two-way direct connection so that it becomes possible to transmit data from one server to any other server via these connections. Each direct connection has to link two different servers, each pair of servers should have at most one direct connection. Y corporation, a business rival of X corporation, made Bob an offer that he couldn't refuse: Bob was asked to connect the servers in such a way, that when server with index v fails, the transmission of data between some other two servers becomes impossible, i.e. the system stops being connected. Help Bob connect the servers.
鲍勃在X公司担任系统管理员。他的第一项任务是使用 m 条双向直连线路连接 n 台服务器,使得任意两台服务器之间均可通过这些连接传输数据。每条直连线路必须连接两台不同的服务器,且任意两台服务器之间至多只能有一条直连线路。Y公司(X公司的商业竞争对手)向鲍勃提出了一项他无法拒绝的提议:要求鲍勃以如下方式连接服务器——当编号为 v 的服务器发生故障时,其余某两台服务器之间的数据传输将变得不可行,即整个系统不再连通。请帮助鲍勃完成服务器的连接。
输入格式
The first input line contains 3 space-separated integer numbers n, m, v (3 ≤ n ≤ 105, 0 ≤ m ≤ 105, 1 ≤ v ≤ n), n — amount of servers, m — amount of direct connections, v — index of the server that fails and leads to the failure of the whole system.
第一行输入包含三个以空格分隔的整数 n、m、v(3 ≤ n ≤ 105,0 ≤ m ≤ 105,1 ≤ v ≤ n),其中 n 表示服务器的数量,m 表示直接连接的数量,v 表示发生故障并导致整个系统崩溃的服务器编号。
输出格式
If it is impossible to connect the servers in the required way, output -1. Otherwise output m lines with 2 numbers each — description of all the direct connections in the system. Each direct connection is described by two numbers — indexes of two servers, linked by this direct connection. The servers are numbered from 1. If the answer is not unique, output any.
如果无法按要求连接服务器,则输出 -1。否则,输出 m 行,每行包含两个数字——表示系统中所有直接连接。每个直接连接由两个数字描述,即通过该直接连接相连的两台服务器的编号。服务器编号从 1 开始。若答案不唯一,输出任意一个即可。
输入输出样例
输入#1
5 6 3
输出#1
1 2 2 3 3 4 4 5 1 3 3 5
输入#2
6 100 1
输出#2
-1
输入解题思路,AI测评打分。不知道怎么写?