結果
問題 | No.630 門松グラフ |
ユーザー |
|
提出日時 | 2018-01-05 21:50:55 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 866 bytes |
コンパイル時間 | 946 ms |
コンパイル使用メモリ | 129,792 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 23:20:10 |
合計ジャッジ時間 | 4,749 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 WA * 15 |
ソースコード
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/2)*(N/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; } } 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) continue; cnt++; writeln(i, " ", j); } } }