結果
| 問題 | No.630 門松グラフ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-02 19:07:02 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 1,500 ms |
| コード長 | 1,210 bytes |
| 記録 | |
| コンパイル時間 | 892 ms |
| コンパイル使用メモリ | 110,508 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-08 21:17:38 |
| 合計ジャッジ時間 | 2,342 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;
int main() {
ll n, m;
cin >> n >> m;
ll l = (n + 1) / 2, r = n - l;
if (m < n - 1 || l * r < m) {
puts("NO");
return 0;
}
puts("YES");
vector<int> val(n);
int cnt = 1;
for (int i = 0; i < n; i += 2) {
val[i] = cnt++;
}
for (int i = 1; i < n; i += 2) {
val[i] = cnt++;
}
for (int i = 0; i < n; ++i) {
if (i) printf(" ");
printf("%d", val[i]);
}
puts("");
for (int i = 0; i < n - 1; ++i) {
printf("%d %d\n", i + 1, i + 2);
}
m -= n - 1;
for (int i = 1; i <= n; i += 2) {
for (int j = 2; j <= n; j += 2) {
if (!m) {
i = n + 1, j = n + 1;
} else if (abs(i-j) == 1) {
} else {
printf("%d %d\n", i, j);
m--;
}
}
}
return 0;
}