結果

問題 No.26 シャッフルゲーム
ユーザー TaK7907TaK7907
提出日時 2017-10-28 05:17:42
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 63 ms / 5,000 ms
コード長 1,706 bytes
コンパイル時間 2,220 ms
コンパイル使用メモリ 104,296 KB
実行使用メモリ 23,748 KB
最終ジャッジ日時 2023-08-14 06:11:15
合計ジャッジ時間 3,567 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
23,700 KB
testcase_01 AC 61 ms
21,804 KB
testcase_02 AC 63 ms
21,792 KB
testcase_03 AC 61 ms
21,660 KB
testcase_04 AC 61 ms
23,748 KB
testcase_05 AC 61 ms
21,644 KB
testcase_06 AC 62 ms
19,604 KB
testcase_07 AC 61 ms
21,680 KB
testcase_08 AC 61 ms
23,708 KB
testcase_09 AC 60 ms
21,548 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

namespace yukicodeX {
    public class Program {
        public static int Solver(System.IO.TextReader reader) {
            const int QTY_CUP= 3;
            var n = 1 << ( QTY_CUP - int.Parse( reader.ReadLine() ) );
            var m = int.Parse( reader.ReadLine() );
            for (var i = 0; i != m; ++i) {
                var buf = MyLib.GetIntList( reader.ReadLine() );
                var p = 1 << ( QTY_CUP - buf[ 0 ] );
                var q = 1 << ( QTY_CUP - buf[ 1 ] );
                var nn = n & ( p | q );
                if (nn > 0) n = n ^ ( p | q );
            }
            return (int)( QTY_CUP - Math.Log( n ) / Math.Log( 2 ) );
        }

        private static void Main() {
            Console.WriteLine( Solver( Console.In ) );
        }
    }

    public class MyLib {
        public static string Ordinalization(int num) {
            string surfix = "stndrdth";
            return string.Format( "{0}{1}", num,
                ( 0 < num % 10 && num % 10 <= 4 ) && ( ( num % 100 ) / 10 != 1 ) ?
                surfix.Substring( ( num % 10 - 1 ) * 2, 2 ) : surfix.Substring( 6 ) );
        }

        public static List<int> GetIntList(string input) {
            return input.Split().ToList<string>().ConvertAll<int>( int.Parse );
        }

        public static List<int> GetIntList(string input, char delimitor) {
            return input.Split( delimitor ).ToList<string>().ConvertAll<int>( int.Parse );
        }

        public static List<int> GetIntList(string input, char[] delimitors) {
            return input.Split( delimitors ).ToList<string>().ConvertAll<int>( int.Parse );
        }
    }
}
0