結果

問題 No.5001 排他的論理和でランニング
ユーザー lzy9lzy9
提出日時 2018-03-16 23:37:58
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 3,807 bytes
コンパイル時間 895 ms
実行使用メモリ 44,864 KB
スコア 8,388,207
最終ジャッジ日時 2020-03-12 19:37:05
ジャッジサーバーID
(参考情報)
judge6 /
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 219 ms
44,864 KB
testcase_01 AC 277 ms
33,172 KB
testcase_02 AC 180 ms
35,068 KB
testcase_03 AC 195 ms
37,036 KB
testcase_04 AC 230 ms
41,664 KB
testcase_05 AC 199 ms
33,916 KB
testcase_06 AC 297 ms
36,580 KB
testcase_07 AC 232 ms
39,512 KB
testcase_08 TLE -
testcase_09 AC 191 ms
0 KB
testcase_10 AC 335 ms
0 KB
testcase_11 AC 271 ms
0 KB
testcase_12 AC 303 ms
0 KB
testcase_13 AC 367 ms
0 KB
testcase_14 AC 220 ms
0 KB
testcase_15 AC 180 ms
0 KB
testcase_16 AC 167 ms
0 KB
testcase_17 AC 222 ms
0 KB
testcase_18 AC 229 ms
0 KB
testcase_19 AC 199 ms
0 KB
testcase_20 AC 176 ms
0 KB
testcase_21 AC 205 ms
0 KB
testcase_22 AC 248 ms
0 KB
testcase_23 AC 180 ms
0 KB
testcase_24 AC 648 ms
0 KB
testcase_25 AC 393 ms
0 KB
testcase_26 AC 454 ms
0 KB
testcase_27 AC 606 ms
0 KB
testcase_28 AC 199 ms
0 KB
testcase_29 AC 212 ms
0 KB
testcase_30 AC 167 ms
0 KB
testcase_31 AC 206 ms
0 KB
testcase_32 AC 181 ms
0 KB
testcase_33 AC 289 ms
0 KB
testcase_34 AC 240 ms
0 KB
testcase_35 AC 198 ms
0 KB
testcase_36 AC 214 ms
0 KB
testcase_37 AC 219 ms
0 KB
testcase_38 AC 178 ms
0 KB
testcase_39 AC 273 ms
0 KB
testcase_40 AC 192 ms
0 KB
testcase_41 AC 173 ms
0 KB
testcase_42 AC 209 ms
0 KB
testcase_43 AC 196 ms
0 KB
testcase_44 AC 210 ms
0 KB
testcase_45 AC 214 ms
0 KB
testcase_46 AC 314 ms
0 KB
testcase_47 AC 180 ms
0 KB
testcase_48 AC 180 ms
0 KB
testcase_49 AC 411 ms
0 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.IO;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int[] dx = new int[] { 0, 0, 1, -1 };
    static int[] dy = new int[] { 1, -1, 0, 0 };

    static void Solve()
    {
        var n = sc.Int();
        var m = sc.Int();

        var a = sc.Int(n);
        var used = new bool[n];
        var xor = 0;

        for (int i = 0; i < m; i++)
        {
            xor ^= a[i];
            used[i] = true;
        }

        double temp = 100;
        double endTemp = 0.000001;
        double alpha = 0.999;
        var lcnt = 0;

        while (endTemp < temp)
        {
            var rnd = new Random();
            var rnd1 = rnd.Next() % n;
            var rnd2 = rnd.Next() % n;

            if (rnd1 == rnd2)
                continue;

            if ((used[rnd1] && used[rnd2]) || (!used[rnd2] && !used[rnd1]))
                continue;

            if (used[rnd2])
            {
                var tmp = rnd1;
                rnd1 = rnd2;
                rnd2 = tmp;
            }

            var prev = xor;

            xor ^= a[rnd1];
            xor ^= a[rnd2];

            if (rnd.NextDouble() < F(prev, xor, temp))
            {
                used[rnd1] = false;
                used[rnd2] = true;
            }
            else
            {
                xor ^= a[rnd1];
                xor ^= a[rnd2];
            }

            temp *= alpha;
            lcnt++;
        }

        var cnt = 0;

        for (int i = 0; i < n; i++)
        {
            if (used[i])
            {
                if (cnt != 0)
                    pr.Write(' ');
                pr.Write(a[i]);
                cnt++;
            }
        }

        pr.WriteLine();
    }

    static double F(double prev, double next, double t)
    {
        return Math.Exp((next - prev) / t);
    }

    static int[,] Mul(int[,] a, int[,] b)
    {
        var ret = new int[a.GetLength(0), b.GetLength(1)];
        for (int i = 0; i < a.GetLength(0); i++)
            for (int j = 0; j < b.GetLength(1); j++)
                for (int k = 0; k < a.GetLength(1); k++)
                    ret[i, j] += a[i, k] * b[k, j];

        return ret;
    }

    static int[,] Pow(int[,] a, int n)
    {
        var b = new int[a.GetLength(1), a.GetLength(0)];

        var f = n % 2 == 1;

        for (int i = 0; i < a.GetLength(0); i++)
            b[i, i] = 1;

        while (n > 0)
        {
            if (n % 2 == 1)
                b = Mul(a, b);


            n >>= 1;
        }

        return b;
    }

    class Coord
    {
        public int x;
        public int y;
    }

    static void Main(string[] args)
    {
        // pr.AutoFlush = true;
        Solve();
        pr.Flush();
        // Console.ReadKey();
    }

    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
}

#region IO
class Scanner
{
    private int _i = 0;
    private string[] line = new string[0];

    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }

    public string Str()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }

        return line[_i++];
    }

    public int Int() => int.Parse(Str());
    public long Long() => long.Parse(Str());
    public double Double() => double.Parse(Str());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] Str(int n) => Enumerate(n, Str);
}

class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion
0