結果

問題 No.630 門松グラフ
ユーザー 🍮かんプリン
提出日時 2020-06-06 17:30:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 153 ms / 1,500 ms
コード長 993 bytes
コンパイル時間 1,333 ms
コンパイル使用メモリ 160,072 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 13:15:29
合計ジャッジ時間 5,193 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.06 17:30:27
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    int k = n / 2;
    if (n - 1 > m || (ll)k * (n - k) < m) {
        puts("NO");
        return 0;
    }
    puts("YES");
    for (int i = 0; i < n; i++) {
        cout << i + 1 << " ";
    }
    cout << endl;
    for (int i = 0; i < k - 1; i++) {
        cout << i + 1 << " " << k + i + 1 << endl;
        cout << i + 1 << " " << k + i + 2 << endl;
        m -= 2;
    }
    cout << k << " " << k + k << endl;
    m--;
    if (n & 1) {
        cout << k << " " << k + k + 1 << endl;
        m--;
    }
    for (int i = 0; i < k; i++) {
        if (m == 0) break;
        for (int j = k; j < n; j++) {
            if (m == 0) break;
            if (k + i == j || k + i + 1 == j) continue;
            cout << i + 1 << " " << j + 1 << endl;
            m--;
        }
    }
    return 0;
}
0