結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  threecourse | 
| 提出日時 | 2018-08-11 12:36:25 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 31 ms / 5,000 ms | 
| コード長 | 3,336 bytes | 
| コンパイル時間 | 1,157 ms | 
| コンパイル使用メモリ | 107,776 KB | 
| 実行使用メモリ | 19,968 KB | 
| 最終ジャッジ日時 | 2024-09-23 06:10:34 | 
| 合計ジャッジ時間 | 2,586 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Competitive
{
    internal class Solution
    {
        public int N;
        public int[] A, B;
        public int count;
        public int win;
        public List<int[]> orders;
        public void Run()
        {
            N = Input.ReadInt();
            A = Input.ReadIntArray();
            B = Input.ReadIntArray();
            orders = new List<int[]>();
            count = 0;
            win = 0;
            var pm = new Permutation(N, Process);
            pm.DFSRun();
            for (int i = 0; i < orders.Count; i++)
                for(int j = 0; j < orders.Count; j++)
                {
                    int w = 0;
                    int l = 0;
                    for (int k = 0; k < N; k++)
                    {
                        if (A[orders[i][k]] > B[orders[j][k]]) w++;
                        else l++;
                    }
                    if (w > l) win++;
                    count++;
                }
            Console.WriteLine(((double)win)/ count);
        }
        public void Process(int[] order)
        {
            orders.Add((int[])order.Clone());
        }
    }
    // libs ----------
    // Permutationを全通り列挙
    class Permutation
    {
        public int N;
        public bool[] F;
        public int[] V;
        public Action<int[]> Process;
        public Permutation(int N, Action<int[]> process)
        {
            this.N = N;
            Process = process;
        }
        public void DFSRun()
        {
            F = new bool[N];
            V = new int[N];
            DFS(0);
        }
        private void DFS(int i)
        {
            if (i == N)
            {
                Process(V);
            }
            else
            {
                for (int k = 0; k < N; k++)
                    if (!F[k])
                    {
                        F[k] = true;
                        V[i] = k;
                        DFS(i + 1);
                        F[k] = false;
                    }
            }
        }
    }
    // common ----------
    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }
        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }
        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }
        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }
        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}
            
            
            
        