天天看点

【codeforces 755E】PolandBall and White-Red graph

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;

int n,k;

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    rei(n),rei(k);
    if (k>=4 || k <=1)
        return pri(-1<<endl),0;
    if (k==2)
    {
        if (n<=4)
            return pri(-1<<endl),0;
        if (n>=5)
        {
            pri(n-1<<endl);
            rep1(i,1,n-1)
                pri(i<<' '<<i+1<<endl);
        }
        return 0;
    }
    if (k==3)
    {
        if (n<=3)
            return pri(-1<<endl),0;
        pri(n-1<<endl);
        rep1(i,1,3)
            pri(i<<' '<<i+1<<endl);
        rep1(i,5,n)
            pri(3<<' '<<i<<endl);
    }
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}