結果

問題 No.5001 排他的論理和でランニング
ユーザー iwkjoseciwkjosec
提出日時 2018-04-02 18:28:34
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,730 bytes
コンパイル時間 884 ms
実行使用メモリ 39,760 KB
スコア 0
最終ジャッジ日時 2020-03-12 20:59:07
ジャッジサーバーID
(参考情報)
judge9 /
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.5.0-beta1-19606-04 (d2bd58c6)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var NM = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NM[0];
        var M = NM[1];
        var A = ReadLine().Split().Select(int.Parse).ToArray();
        var u = new int[M];
        var uu = Enumerable.Range(M, N - M).ToList();
        var r = new XorShift();
        var res = A.Take(M).Aggregate((x, y) => x ^ y);
        for (int i = 0; i < M; i++)
        {
            u[i] = i;
        }

        while (res != 0xFFFFF)
        {
            var a = r.Next(M);
            var b = r.Next(N - M);

            res ^= A[u[a]];
            res ^= A[uu[b]];
            uu.RemoveAt(b);
            uu.Add(u[a]);
            u[a] = uu[b];
        }
        for (int i = 0; i < M; i++)
        {
            Write($"{A[u[i]]} ");
        }
        WriteLine();
    }
}

public class XorShift
{
    uint x = 123456789;
    uint y = 362436069;
    uint z = 521288629;
    uint w = 88675123;

    public XorShift()
    {
        var t = (uint)Environment.TickCount;
        x ^= t;
        y ^= Rotate(t, 17);
        z ^= Rotate(t, 31);
        w ^= Rotate(t, 18);
    }

    uint Rotate(uint u, int n) => (u << n) + (u >> 32 - n);

    public int Next()// [0, int.MaxValue)                  
    {
        var t = x ^ x << 11;
        x = y; y = z; z = w;
        t = w = w ^ w >> 19 ^ t ^ t >> 8;
        if (t > int.MaxValue) t = ~t;
        return (int)(t == int.MaxValue ? --t : t);
    }

    public int Next(int maxValue) => (int)(NextDouble() * maxValue);// [0, maxValue)

    public double NextDouble() => (double)Next() / int.MaxValue;// [0.0, 1.0)
}
0