結果

問題 No.690 E869120 and Constructing Array 4
ユーザー AreTrashAreTrash
提出日時 2018-05-19 00:17:06
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 70 ms / 1,000 ms
コード長 1,147 bytes
コンパイル時間 2,323 ms
コンパイル使用メモリ 105,748 KB
実行使用メモリ 23,104 KB
最終ジャッジ日時 2023-09-10 23:27:58
合計ジャッジ時間 5,118 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
23,076 KB
testcase_01 AC 64 ms
23,056 KB
testcase_02 AC 67 ms
20,988 KB
testcase_03 AC 62 ms
18,952 KB
testcase_04 AC 63 ms
21,008 KB
testcase_05 AC 62 ms
23,052 KB
testcase_06 AC 64 ms
19,108 KB
testcase_07 AC 65 ms
20,964 KB
testcase_08 AC 66 ms
21,048 KB
testcase_09 AC 70 ms
20,996 KB
testcase_10 AC 64 ms
20,992 KB
testcase_11 AC 66 ms
23,004 KB
testcase_12 AC 66 ms
21,008 KB
testcase_13 AC 61 ms
20,972 KB
testcase_14 AC 64 ms
19,048 KB
testcase_15 AC 63 ms
20,952 KB
testcase_16 AC 64 ms
20,972 KB
testcase_17 AC 61 ms
20,976 KB
testcase_18 AC 55 ms
20,764 KB
testcase_19 AC 60 ms
22,972 KB
testcase_20 AC 66 ms
21,108 KB
testcase_21 AC 64 ms
23,104 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;

namespace No690
{
    public class Program
    {
        struct Edge
        {
            public int From;
            public int To;

            public Edge(int from, int to)
            {
                From = from;
                To = to;
            }
        }

        public static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());

            if (K == 0)
            {
                Console.WriteLine("3 1");
                Console.WriteLine("1 2");
                return;
            }

            var v = (int)Math.Ceiling(Math.Log(K, 2)) + 2;

            var ans = new List<Edge>();
            for (var i = 1; i <= v; i++)
            for (var j = i + 1; j <= v; j++)
            {
                ans.Add(new Edge(i, j));
            }

            for (int i = (1 << (v - 2)) - K, j = 2; i > 0; i >>= 1, j++)
            {
                if ((i & 1) == 1) ans.Remove(new Edge(j, v));
            }

            Console.WriteLine($"{v} {ans.Count}");
            ans.ForEach(e => Console.WriteLine($"{e.From} {e.To}"));
        }
    }
}
0