結果

問題 No.630 門松グラフ
ユーザー pekempeypekempey
提出日時 2018-01-05 22:10:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 700 bytes
コンパイル時間 760 ms
コンパイル使用メモリ 69,748 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 06:39:59
合計ジャッジ時間 5,213 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 31 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  if (m > 1LL * (n / 2) * ((n + 1) / 2)) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;

  for (int i = 0; i < n; i++) {
    if (i > 0) cout << ' ';
    cout << i + 1;
  }
  cout << endl;
  for (int j = 0; j < (n + 1) / 2; j++) {
    cout << 1 << ' ' << j + n / 2 + 1 << endl;
    m--;
  }
  for (int j = 1; j < n / 2; j++) {
    cout << n / 2 + 1 << ' ' << j + 1 << endl;
    m--;
  }
  for (int i = 1; i < n / 2; i++) {
    for (int j = 1; j < (n + 1) / 2 && m > 0; j++) {
      cout << i + 1 << ' ' << j + n / 2 + 1 << endl;
      m--;
    }
  }
}
0