Codeforces 22C System Administrator (structural water problem)

Source: Internet
Author: User

Reprint Please specify source: http://www.cnblogs.com/fraud/--by fraud

System Administrator

Bob got a job as a system administrator in X Corporation. His first task is to connect n servers with the help of M. two-way direct connection so it becomes possible to transmit data from one server to any other server via these connections. Each of the direct connection has to link the different servers, each pair of servers should having at most one direct connection. Y Corporation, a business rival of X Corporation, made Bob an offer that he couldn ' t Refuse:bob is asked to connect the Servers in such a is, that's when server with index v fails, the transmission of data between some and other s Ervers 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 ≤10 5, 0≤ m ≤105, 1≤ vn), n -amount of servers, m -amount of direct connections, v -index of the server that fails and leads to the Failur E of the whole system.

Output

If It is impossible to connect the servers in the required, output -1. Otherwise output m lines with 2 numbers each-description of all the direct connections in the system. Each direct connection was described by and numbers-indexes of the servers, linked by this direct connection. The servers is numbered from 1. If The answer is isn't 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

Test Instructions

Given the point of N, the M-Edge, and a node V, ask if you can construct a connected graph with V as the cut point.

Divide the remaining n-1 points into two parts, 1 and n-2. And then just do it.

1#include <iostream>2#include <cstdio>3#include <vector>4#include <cstring>5 using namespacestd;6typedefLong Longll;7 intMain ()8 {9Ios::sync_with_stdio (false);Ten ll N,m,v; OneCin>>n>>m>>v; All Sum2= (LL) (n1) * (n2)/2+1; -     if(m<n-1|| M&GT;SUM2)//((n-1) * (n-2)/2+1)) -     { thecout<<-1<<Endl; -}Else{ -         ints=1; -         if(v==1) s++; +vector<int>v1; -          for(intI=1; i<=n;i++) +         { A             if(i!=s) v1.push_back (i); at         } -cout<<v<<" "<<s<<Endl; -         intsz=v1.size (); -          for(intI=0; i<sz-1; i++) -         { -cout<<v1[i]<<" "<<v1[i+1]<<Endl; in         } -m-=n-1; to          for(intI=0; i<sz&&m;i++){ +              for(intj=i+2; j<sz&&m;j++){ -cout<<v1[i]<<" "<<v1[j]<<Endl; them--; *             } $         }Panax Notoginseng     } -   the     return 0; +}
code June

Codeforces 22C System Administrator (structural water problem)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.