結果

問題 No.630 門松グラフ
ユーザー homesentinelhomesentinel
提出日時 2018-01-05 22:40:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,850 bytes
コンパイル時間 1,200 ms
コンパイル使用メモリ 117,560 KB
実行使用メモリ 4,572 KB
最終ジャッジ日時 2023-08-24 21:00:02
合計ジャッジ時間 7,188 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,M;
    cin >> N >> M;

    if( M > N*(N-1)/2 || M < N - 1){
        cout << "NO" << endl;
        return 0;
    }
    if(N % 2 == 0){
        if(M > ((N-1)/2)*((N-1)/2+1) ){
            cout << "NO" << endl;
            return 0;
        }
        if(M > ((N-1)/2)*((N-1)/2+1) + (N-1)/2){
            cout << "NO" << endl;
            return 0;
        }
    }

    vector<int> a(N);
    if(N % 2){
        int cnt = 0;
        rep(i,0,(N-1)/2+1){
//            a.push_back(++cnt);
            a[2*i] = ++cnt;
        }
        cnt = 250000;
        rep(i,0,(N-1)/2){
//            a.push_back(++cnt);
            a[2*i+1] = ++cnt;
        }
    }else{
        int cnt = 0;
        rep(i,0,N/2){
//            a.push_back(++cnt);
            a[2*i] = ++cnt;

        }
        cnt = 250000;
        rep(i,0,N/2){
//            a.push_back(++cnt);
            a[2*i+1] = ++cnt;
        }
    }
    vector<pair<int,int> > vp;
    int dist = 1;
    int pt = 0;
    while(M > 0){
        M--;
        if(pt + dist >= N){
            pt = 0;
            dist += 2;
        }
        vp.emplace_back(pt,pt+dist);
        pt += dist;
    }

    cout << "YES" << endl;
    rep(i,0,N){
        cout << a[i];
        if(i == N-1) cout << endl;
        else cout << " ";
    }
    rep(i,0,vp.size()){
        cout << vp[i].first + 1 << " " << vp[i].second + 1 << endl;
    }

    return 0;
}
0