結果

問題 No.862 XORでX
コンテスト
ユーザー kakel-san
提出日時 2026-04-09 22:28:28
言語 C#
(.NET 10.0.201)
コンパイル:
dotnet_c
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 2,568 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 18,736 ms
コンパイル使用メモリ 175,368 KB
実行使用メモリ 206,952 KB
最終ジャッジ日時 2026-04-09 22:28:57
合計ジャッジ時間 14,740 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (130 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

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();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, x) = (c[0], c[1]);
        WriteLine(string.Join("\n", Divide(n, x)));
    }
    static List<int> Divide(int n, int x)
    {
        if (n > 50000)
        {
            var s1 = DivideInt(100005 - n, x ^ 1);
            var ans = new List<int>();
            for (var i = 1; i <= 100005; ++i) if (!s1.Contains(i)) ans.Add(i);
            return ans;
        }
        else
        {
            return DivideInt(n, x).ToList();
        }
    }
    static HashSet<int> DivideInt(int n, int x)
    {
        var ans = new HashSet<int>();
        var rest = x;
        for (var i = 1; i < n; ++i)
        {
            ans.Add(i);
            rest ^= i;
        }
        if (rest >= 100006)
        {
            ans.Add(rest ^ 32768);
            if (n <= 32768)
            {
                ans.Remove(n - 1);
                ans.Add((n - 1) ^ 32768);
            }
            else
            {
                ans.Remove(32767);
                ans.Add(65535);
            }
        }
        else if (rest == 0)
        {
            ans.Add(65536);
            ans.Remove(1);
            ans.Add(65537);
        }
        else if (rest == 1)
        {
            if (ans.Contains(1))
            {
                ans.Add(65537);
                ans.Remove(2);
                ans.Add(65538);
            }
            else
            {
                ans.Add(1);
            }
        }
        else if (rest < n)
        {
            if ((rest ^ 65536) > 100005)
            {
                ans.Add(rest ^ 98304);
                ans.Remove(1);
                ans.Add(98305);
            }
            else
            {
                ans.Add(rest ^ 65536);
                ans.Remove(1);
                ans.Add(65537);
            }
        }
        else ans.Add(rest);
        return ans;
    }
    class Info
    {
        public int L;
        public int R;
        public int U;
        public Info(int l, int r, int u = 0)
        {
            L = l; R = r; U = u;
        }
    }
}
0