結果
| 問題 | No.2929 Miracle Branch | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-11-01 00:41:35 | 
| 言語 | C# (.NET 8.0.404) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 195 ms / 2,000 ms | 
| コード長 | 1,853 bytes | 
| コンパイル時間 | 8,275 ms | 
| コンパイル使用メモリ | 165,076 KB | 
| 実行使用メモリ | 196,396 KB | 
| 最終ジャッジ日時 | 2024-11-01 00:41:55 | 
| 合計ジャッジ時間 | 20,576 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 43 | 
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (106 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/
ソースコード
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var x = long.Parse(ReadLine());
        var prev = -1;
        var ans = new List<int[]>();
        var color = new List<char>();
        if (x == 1)
        {
            color.Add('b');
            color.Add('g');
            ans.Add(new int[] { 1, 2 });
        }
        {
            while (x % 4 == 0)
            {
                color.Add('b');
                var br = color.Count;
                if (prev > 0) ans.Add(new int[] { prev, br });
                for (var j = 0; j < 4; ++j)
                {
                    color.Add('g');
                    ans.Add(new int[] { br, color.Count });
                }
                prev = br;
                x /= 4;
            }
        }
        for (var i = 2; i <= 200000; ++i)
        {
            while (x % i == 0)
            {
                color.Add('b');
                var br = color.Count;
                if (prev > 0) ans.Add(new int[] { prev, br });
                for (var j = 0; j < i; ++j)
                {
                    color.Add('g');
                    ans.Add(new int[] { br, color.Count });
                }
                prev = br;
                x /= i;
            }
        }
        if (x > 1 || color.Count > 200000)
        {
            WriteLine(-1);
            return;
        }
        WriteLine(color.Count);
        WriteLine(string.Join("\n", ans.Select(ai => string.Join(" ", ai))));
        WriteLine(string.Join(" ", color));
    }
}
            
            
            
        