結果
問題 | No.630 門松グラフ |
ユーザー |
|
提出日時 | 2018-01-05 21:57:19 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 60 ms / 1,500 ms |
コード長 | 898 bytes |
コンパイル時間 | 783 ms |
コンパイル使用メモリ | 130,448 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 23:20:34 |
合計ジャッジ時間 | 3,335 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.datetime; void main() { auto s = readln.split.map!(to!int).array; auto N = s[0]; auto M = s[1]; if (M < N-1 || M > (N.to!long/2)*(N.to!long/2+N%2)) { writeln("NO"); return; } writeln("YES"); int[] A; foreach (i; 1..N+1) { if (i%2 == 1) { A ~= i/2+1; } else { A ~= i/2+N/2+N%2; } } A.map!(to!string).join(" ").writeln; foreach (i; 0..N-1) writeln(i+1, " ", i+2); int cnt = N-1; for (int i = 1; i <= N && cnt < M; i += 2) { for (int j = 2; j <= N && cnt < M; j += 2) { if (j == i+1 || j == i-1) continue; cnt++; writeln(i, " ", j); } } }