結果

問題 No.630 門松グラフ
ユーザー imulanimulan
提出日時 2018-01-05 22:06:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 172 ms / 1,500 ms
コード長 1,358 bytes
コンパイル時間 1,723 ms
コンパイル使用メモリ 177,508 KB
実行使用メモリ 8,680 KB
最終ジャッジ日時 2023-08-24 20:47:48
合計ジャッジ時間 5,284 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 167 ms
8,580 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 168 ms
8,680 KB
testcase_27 AC 168 ms
8,672 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 151 ms
8,108 KB
testcase_30 AC 172 ms
8,560 KB
testcase_31 AC 153 ms
7,908 KB
testcase_32 AC 81 ms
5,664 KB
testcase_33 AC 84 ms
5,848 KB
testcase_34 AC 127 ms
7,120 KB
testcase_35 AC 94 ms
6,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

void solve(){
    int n,m;
    cin >>n >>m;

    int A=(n+1)/2, B=n-A;
    if(A*B<m || m<n-1){
        cout << "NO" << endl;
        return;
    }
    
    vector<int> a(n);
    rep(i,n) a[i]=i+1;

    vector<pi> e;
    set<pi> s;

    int aa=1,bb=A+1;
    rep(i,n-1){
        e.pb({aa,bb});
        s.insert({aa,bb});
        if(i%2==0) ++aa;
        else ++bb;
        --m;
    }

    if(m>0){
        rep(i,A)rep(j,B){
            pi E(i+1,A+j+1);
            if(!s.count(E)){
                e.pb(E);
                s.insert(E);
                --m;
            }
            if(m==0){
                i=A;
                j=B;
            }
        }
    }

    cout << "YES" << endl;
    rep(i,n) cout << a[i] << " \n"[i==n-1];
    for(const auto &p:e) cout << p.fi << " " << p.se << endl;
}

int main(){
    solve();
    return 0;
}
0