Codeforces_953C_Mahmoud and Ehab and the wrong algorithm(构造)

原创 2018年04月16日 19:54:41

传送门

思路:分情况构造,一定 正确的树是一条直线。不正确的话是当n>=6的时候,只需要在1上挂2,3,4,其他挂在2上就行。画画图就很容易出来啦。

#include<bits/stdc++.h>
#define debug(a) cout << #a << " " << a << endl
#define LL long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-6
const int N=1e5+7;
using namespace std;
int main ()
{
    //yyy_3y
    //freopen("1.in","r",stdin);
    int n; scanf("%d",&n);
    if(n<6){
        printf("-1\n");

    }else {
        for(int i=2;i<=4;i++) printf("1 %d\n",i);
        for(int i=5;i<=n;i++) printf("2 %d\n",i);
    }
    for(int i=1;i<n;i++){
        printf("%d %d\n",i,i+1);
    }
    return 0;
}
版权声明: https://blog.csdn.net/yyy_3y/article/details/79965431

Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor

Mahmoud and Ehab are on the third stage of their adventures now. As you know, Dr. Evil likes sets. T...
  • SSimpLe_Y
  • SSimpLe_Y
  • 2017-09-20 08:58:35
  • 626

Codeforces 959 C. Mahmoud and Ehab and the wrong algorithm

题目链接C. Mahmoud and Ehab and the wrong algorithmtime limit per test2 secondsmemory limit per test256 ...
  • xiuya19
  • xiuya19
  • 2018-04-04 17:07:43
  • 17

Mahmoud and Ehab and the wrong algorithm

Mahmoud was trying to solve the vertex cover problem on trees. The problem statement is:Given an und...
  • ujn20161222
  • ujn20161222
  • 2018-04-06 14:57:20
  • 17

Codeforces - 862C Mahmoud and Ehab and the xor

C. Mahmoud and Ehab and the xor Mahmoud and Ehab are on the third stage of their adventures...
  • lzc504603913
  • lzc504603913
  • 2017-09-20 15:55:20
  • 654

Codeforces 862 C. Mahmoud and Ehab and the xor (技巧)

Description Mahmoud and Ehab are on the third stage of their adventures now. As you know, Dr. Evil...
  • qq_28954601
  • qq_28954601
  • 2017-09-20 18:06:18
  • 395

Codeforces - 862B Mahmoud and Ehab and the bipartiteness

B. Mahmoud and Ehab and the bipartiteness Mahmoud and Ehab continue their adventures! As ev...
  • lzc504603913
  • lzc504603913
  • 2017-09-20 11:51:07
  • 482

codeforces 862B B. Mahmoud and Ehab and the bipartiteness

codeforces 862B B. Mahmoud and Ehab and the bipartiteness B. Mahmoud and Ehab and the biparti...
  • qq_39482280
  • qq_39482280
  • 2017-09-20 14:47:19
  • 385

binary string codeforces 862D 交互题,二分答案

D. Mahmoud and Ehab and the binary string time limit per test 2 seconds memory limit per ...
  • weixin_37517391
  • weixin_37517391
  • 2017-09-20 23:44:39
  • 374

codeforces 959E Mahmoud and Ehab and the xor-MST

http://www.elijahqi.win/archives/2945 题目描述 Ehab is interested in the bitwise-xor operation and the...
  • elijahqi
  • elijahqi
  • 2018-04-07 10:16:58
  • 71

Mahmoud and Ehab and the binary string CodeForces - 862D 二分+交互题

题目大意:有一个长度为n的二进制串,你可以自己猜n长度的字符串,然后问题目, 题目会告诉你不一样的位置有几个,最多提问十五次。然后提交任意一个0的位置和任意一个1的位置,题目保证二进制串中最少有一个1...
  • lcuwb
  • lcuwb
  • 2017-09-24 15:08:32
  • 108
收藏助手
不良信息举报
您举报文章:Codeforces_953C_Mahmoud and Ehab and the wrong algorithm(构造)
举报原因:
原因补充:

(最多只允许输入30个字)