码迷,mamicode.com
首页 > 其他好文 > 详细

「日常训练」Regular Bridge(Codeforces Round 306 Div.2 D)

时间:2018-10-03 20:58:35      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:fir   false   bridge   cin   def   i+1   +=   ==   second   

题意与分析

图论基础+思维题。

代码

#include <bits/stdc++.h>
#define MP make_pair
#define PB emplace_back
#define fi first
#define se second
#define ZERO(x) memset((x), 0, sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define rep(i, a, b) for (repType i = (a); i <= (b); ++i)
#define per(i, a, b) for (repType i = (a); i >= (b); --i)
#define QUICKIO                      ios::sync_with_stdio(false);     cin.tie(0);                      cout.tie(0);
using namespace std;
using ll=long long;
using repType=int;

int main()
{
    int k; cin>>k;
    if(k%2==0) cout<<"NO"<<endl;
    else 
    {
        cout<<"YES"<<endl;
        cout<<4*k-2<<" "<<2*k*(k-1)+k<<endl;
        cout<<1<<" "<<2<<endl;
        rep(i,3,3+k-1-1) cout<<1<<" "<<i<<endl;
        rep(i,k+2,k+2+k-1-1) cout<<2<<" "<<i<<endl; // k+2 ~ 2*k
        rep(i,3,3+k-1-1)
        {
            rep(j,2*k+1,2*k+1+k-1-1) // 2*k+1 ~ 3*k-1
            {
                cout<<i<<" "<<j<<endl;
            }
        }
        rep(i,k+2,2*k)
        {
            rep(j,3*k,3*k+k-1-1) // 3*k ~ 4*k-2
            {
                cout<<i<<" "<<j<<endl;
            }
        }
        for(int i=2*k+1;i<=3*k-1;i+=2)
        {
            cout<<i<<" "<<i+1<<endl;
        }
        for(int i=3*k;i<=4*k-2;i+=2)
        {
            cout<<i<<" "<<i+1<<endl;
        }

    }
    return 0;
}

「日常训练」Regular Bridge(Codeforces Round 306 Div.2 D)

标签:fir   false   bridge   cin   def   i+1   +=   ==   second   

原文地址:https://www.cnblogs.com/samhx/p/cfr306d2d.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!