結果

問題 No.1880 Many Ways
ユーザー keymoonkeymoon
提出日時 2022-01-03 13:13:54
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,441 bytes
コンパイル時間 15,614 ms
コンパイル使用メモリ 169,108 KB
実行使用メモリ 185,620 KB
最終ジャッジ日時 2024-04-21 06:31:21
合計ジャッジ時間 29,053 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
29,544 KB
testcase_01 AC 52 ms
29,560 KB
testcase_02 AC 49 ms
29,312 KB
testcase_03 AC 50 ms
29,552 KB
testcase_04 AC 47 ms
29,696 KB
testcase_05 AC 49 ms
29,440 KB
testcase_06 AC 50 ms
29,552 KB
testcase_07 AC 48 ms
29,312 KB
testcase_08 AC 49 ms
29,552 KB
testcase_09 AC 49 ms
29,552 KB
testcase_10 AC 50 ms
29,696 KB
testcase_11 AC 50 ms
29,568 KB
testcase_12 AC 52 ms
29,544 KB
testcase_13 AC 49 ms
185,620 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (86 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var a = long.Parse(Console.ReadLine());

        int layers = 40;
        int n = 1 + layers * 3;
        int[] prevs = { 1 };
        int nxtA = 2;
        int nxtB = 3;
        int nxtC = 4;

        // 1 - A0 - A1 - A2
        //   \    x    x
        //     B0 - B1 - B2
        //      |         |
        //     C0 - C1 - C2
        List<int> cs = new List<int>();
        List<(int, int)> edges = new List<(int, int)>();
        for (int i = 0; i < layers; i++)
        {
            int[] nxts = { nxtA, nxtB };
            cs.Add(nxtC);
            foreach (var prev in prevs)
                foreach (var nxt in nxts)
                    edges.Add((prev, nxt));
            if ((a >> i & 1) == 1) edges.Add((nxtB, nxtC));
            nxtA += 3;
            nxtB += 3;
            nxtC += 3;
            prevs = nxts;
        }
        for (int i = 1; i < cs.Count; i++)
        {
            edges.Add((cs[i - 1], cs[i]));
        }
        Console.WriteLine($"{n} {edges.Count}");
        foreach (var (s, t) in edges)
        {
            Console.WriteLine($"{s} {t}");
        }
    }
}
0