Description
Bob got a job as a system administrator in X Corporation. His first task is to connectn servers with the help'sm two-way direct connection so it becomes PO Ssible 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-, that's when server with indexv fails, the transmission of data between some and other server s 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, fails and leads to the failure 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 Input
Input
5 6 3
Output
1 22 33 44 51 33 5
Input
6 100 1
Output
-1
This is another problem, Qaq.
Test instructions: Known points, the number of edges, the number of cut points (always thought to be the number of cut points, can not ask ah = =), to determine whether the conditions of the diagram, output
Procedure: First of all to determine whether to meet the conditions, we need to find a number of sides and points of the relationship, the lower limit of points must be equal to the number of points, the upper limit of the point can think: since there is a spot is cut top, then the remaining points into two regiment, respectively is a complete picture, and then cut the top is the So want to think of the two groups of equal number of times the number of sides, the upper limit can be asked. We follow this idea can be in order to write the side ~ ~
#include <iostream> #include <cstdio>using namespace Std;int n,m,v;int main () { scanf ("%d%d%d", &n, &M,&V); { if (m<n-1| | M> (n*n-3*n+4)/2) printf (" -1\n"); else { int la; for (int i=1;i<=n;i++) { if (i!=v) { printf ("%d%d\n", i,v); la=i; break; } } m-= (n-1); for (int i=1;i<la&&m;i++) {for (int j=i+1;j<la&&m;j++) { if (i!=v& &j!=v) { printf ("%d%d\n", i,j); m-- ; }}}} return 0;}
Wrote a day VTK feel ACM code is really short touching ah =
codeforces22c System Administrator "Given a cut-top output Edge BCC"