转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud

System Administrator

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.

Input

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.

Output

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.

Sample test(s)
Input
5 6 3
Output
1 2
2 3
3 4
4 5
1 3
3 5
Input
6 100 1
Output
-1

题意

给出n的点,m条边,和一个结点v,问能否构造出一个以v为割点的连通图

将剩余n-1个点分成两部分,1个和n-2个。然后直接搞就行

 #include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
ll n,m,v;
cin>>n>>m>>v;
ll sum2=(ll)(n-)*(n-)/+;
if(m<n-||m>sum2)//((n-1)*(n-2)/2+1))
{
cout<<-<<endl;
}else{
int s=;
if(v==)s++;
vector<int>v1;
for(int i=;i<=n;i++)
{
if(i!=s)v1.push_back(i);
}
cout<<v<<" "<<s<<endl;
int sz=v1.size();
for(int i=;i<sz-;i++)
{
cout<<v1[i]<<" "<<v1[i+]<<endl;
}
m-=n-;
for(int i=;i<sz&&m;i++){
for(int j=i+;j<sz&&m;j++){
cout<<v1[i]<<" "<<v1[j]<<endl;
m--;
}
}
} return ;
}

代码君

codeforces 22C System Administrator(构造水题)的更多相关文章

  1. CodeForces 22C System Administrator

    把v和2结点交换, 1和v连,其它点和v之间能够互相连. #include <iostream> #include <cstdlib> #include <cstring ...

  2. 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root

    题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...

  3. codeforces 659A A. Round House(水题)

    题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. codeforces 577B B. Modulo Sum(水题)

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  6. codeforces 696A Lorenzo Von Matterhorn 水题

    这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...

  7. CodeForces 589I Lottery (暴力,水题)

    题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...

  8. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

  9. codeforces 710A A. King Moves(水题)

    题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...

随机推荐

  1. C#如何设置下拉COMMBOX为不可输入,只有下拉条目

    设置下拉框的DropDownStyle属性为DropDownList

  2. js过滤emoji表情符号

    手机端常常会遇到用户输入框,输入emoji,如果是数据库是UTF8,会遇到报错:SQLException: Incorrect string value: '\xF0\x9F\x98\x84' for ...

  3. Oracle BigFile

    http://blog.chinaunix.net/uid-20779720-id-3078273.html

  4. 三元运算符和GridView数据显示

    三元运算符嵌套使用:<%# Eval("InsertType").ToString() == "0" ? "数据库" : Eval(& ...

  5. C51变量的存储

    一.全局变量和局部变量 全局变量和局部变量的区别在于作用域的不同.此外还有静态全局变量和静态局部变量. 全局变量作用域为全局,在一个源文件中定义,其他的源文件也可以应用.在其他的源文件中使用exter ...

  6. (转)open和fopen的区别:

    fopen与open的区别 open和fopen的区别: 1.缓冲文件系统缓冲文件系统的特点是:在内存开辟一个“缓冲区”,为程序中的每一个文件使用,当执行读文件的操作时,从磁盘文件将数据先读入内存“缓 ...

  7. centos下安装mysql步骤

    转载自http://zym820910.iteye.com/blog/671566 一.下载MySQL5.0和相关perl包 1.官网[url] http://dev.mysql.com/downlo ...

  8. device tree website

    每一个设备都有相对应的初始化程序,dts的写法可以参照Documentations/devicetree/下面的文档 http://bbs.chinaunix.net/thread-4139331-1 ...

  9. 通过Excel来集中管理资源文件

     在支持双语或多语种项目中,常常需要编辑多个文件来添加资源项,感觉比较繁琐,所以想做一个可以集中管理资源文件的工具.借助Excel,使用Excel来记录,并且通过Excel可以进行分页分模块来规划 ...

  10. hdu 5612 Baby Ming and Matrix games(dfs暴力)

    Problem Description These few days, Baby Ming is addicted to playing a matrix game. Given a n∗m matr ...