CodeForces 22C System Administrator 小水怡情 图论+构造

题目链接:点击打开链接

构造一个星形图+一个完全图就好了。。

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <math.h>
using namespace std;
#define inf 10000000
#define ll __int64
#define N 2105

ll n, m, v;
int main(){
	ll i, j;
	while(cin>>n>>m>>v){
		ll u = n;
		if(v==n)u--;
		if(!(n-1<=m&&m<=((n*n-3*n+4)/2))){puts("-1");continue;}
		m -= (n-1);
		for(i=1;i<=n;i++)
			if(i!=v)
				cout<<v<<" "<<i<<endl;
		for(i=1;i<=n&&m;i++)
			if(i!=u&&i!=v)
			for(j=i+1;j<=n&&m;j++)
				if(j!=u&&j!=v)
					cout<<i<<" "<<j<<endl, m--;
	}
	return 0;
}
/*
3
40 -83
52 -80
-21 -4

*/

CodeForces 22C System Administrator 小水怡情 图论+构造,布布扣,bubuko.com

时间: 2024-12-19 16:23:04

CodeForces 22C System Administrator 小水怡情 图论+构造的相关文章

CodeForces 22C System Administrator

把v和2结点交换, 1和v连,其他点和v之间可以互相连. #include <iostream> #include <cstdlib> #include <cstring> #include <string> #include <cstdio> #include <cmath> #include <algorithm> using namespace std; int n,m,v,flag,i,cnt,j; int mai

codeforces 22C System Administrator(构造水题)

转载请注明出处: 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

CodeForces Round#22 C System Administrator 构造割点图

题目描述: Description 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 thes

UESTC_小panpan学图论 2015 UESTC Training for Graph Theory&lt;Problem J&gt;

J - 小panpan学图论 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit Status 小panpan不会图论,所以图论专题他非常刻苦地学习图论. 今天他认真地学习了萌神的ppt,学习了一下Floyd算法,手持两把锟斤拷的他, 口中疾呼烫烫烫,马上找了到OJ上找了道FLoyd的题: n个点,m边的无向连通图,无重边,无自环,每条边的长度都是1,求任意两点之间的

Linux - System Administrator Duties

The sections below summarize some of the main tasks that administrators are expected to perform. 1. Account Provisioning The system administrator adds accounts for new users, removes the accounts of users that are no longer active, and handles all th

解决方法:An error occurred on the server when processing the URL. Please contact the system administrator

在WINDOWS7或SERVER2008上安装了IIS7.5,调试ASP程序时出现以下错误: An error occurred on the server when processing the URL. Please contact the system administrator 解决方法如下:     设置方法一: 以管理员身份运行CMD,将目录定位到%windir%\system32\inetsrv\,然后执行appcmd set config -section:asp -script

【HDU 4940】Destroy Transportation system(数据水/无源无汇带上下界可行流)

Description Tom is a commander, his task is destroying his enemy’s transportation system. Let’s represent his enemy’s transportation system as a simple directed graph G with n nodes and m edges. Each node is a city and each directed edge is a directe

Requirements of an SAP system administrator

Requirements of an SAP system administrator Have a "proper" attitude Protect and safeguard the system. The system administrator is the "guardian" of the system. Be willing to work the hours required to support the system. Certain tasks

ERROR Function not available to this responsibility.Change responsibilities or contact your System Administrator.

APPLIES TO: Navigation:  Help > Diagnostics > Custom Code > Personalize  or  Help > Diagnostics > Examine The Issue can occur from any form or from any responsibility. SYMPTOMS The following Error message is displayed when trying to access