結果

問題 No.630 門松グラフ
ユーザー simansiman
提出日時 2022-05-09 15:46:13
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 501 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 11,272 KB
実行使用メモリ 28,340 KB
最終ジャッジ日時 2023-09-23 14:20:17
合計ジャッジ時間 10,285 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 70 ms
15,084 KB
testcase_02 AC 72 ms
15,312 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 73 ms
15,040 KB
testcase_06 AC 72 ms
15,288 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 73 ms
15,084 KB
testcase_10 AC 74 ms
15,292 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 77 ms
15,164 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 74 ms
15,144 KB
testcase_22 WA -
testcase_23 AC 78 ms
15,044 KB
testcase_24 WA -
testcase_25 AC 91 ms
17,456 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
E = Hash.new { |h, k| h[k] = [] }

if M < N - 1
  puts "NO"
  exit
end

m = M
cur = 0

(N - 1).times do |u|
  E[u] << u + 1
  m -= 1
end

while m > 0 && cur < N
  es = E[cur].size

  v = cur + 2 * es + 1

  if v < N
    E[cur] << v
    m -= 1
  else
    cur += 1
  end
end

if m > 0
  puts "NO"
else
  puts "YES"
  puts [*1..N].map { |v| v.even? ? v : 1_000_000 - v }.join(' ')

  E.each do |u, nums|
    nums.each do |v|
      puts "#{u + 1} #{v + 1}"
    end
  end
end
0