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 main()
{
    while(~scanf("%d%d%d",&n,&m,&v))
    {
        flag=0;
        if((n-1)*(n-2)/2+1<m) flag=1;
        if(m<n-1) flag=1;
        if(flag)
        {
            printf("-1\n");
            continue;
        }
        cnt=n-1;
        for(i=1;i<n;i++)
        {
            if(i==2) printf("%d ",v);
            else if(i==v) printf("%d ",2);
            else printf("%d ",i);
            if(i+1==2) printf("%d\n",v);
            else if(i+1==v) printf("%d\n",2);
            else printf("%d\n",i+1);
        }
        for(i=2;i<n&&cnt!=m;i++)
        {
            for(j=i+2;j<=n&&cnt!=m;j++)
            {
                cnt++;
                if(i==2) printf("%d ",v);
                else if(i==v) printf("%d ",2);
                else printf("%d ",i);
                if(j==2) printf("%d\n",v);
                else if(j==v) printf("%d\n",2);
                else printf("%d\n",j);
            }
        }
    }
    return 0;
}

CodeForces 22C System Administrator

时间: 2024-10-07 04:34:53

CodeForces 22C System Administrator的相关文章

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

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

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

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

解决IIS7运行ASP提示错误:An error occurred on the server when processing the URL. Please contact the system administrator

原文:解决IIS7运行ASP提示错误:An error occurred on the server when processing the URL. Please contact the system administrator 在WINDOWS7或SERVER2008上安装了IIS7,调试ASP程序时出现以下错误: An error occurred on the server when processing the URL. Please contact the system admini

codeforces22c System Administrator【给定一个割顶输出边 BCC】

Description Bob got a job as a system administrator in X corporation. His first task was to connectn servers with the help ofm two-way direct connection so that it becomes possible to transmit data from one server to any other server via these connec