結果

問題 No.630 門松グラフ
ユーザー nebukuro09nebukuro09
提出日時 2018-01-05 21:53:54
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 882 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 132,152 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-12 23:20:22
合計ジャッジ時間 5,151 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
        }
    }

    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);
        }
    }
}
0