結果

問題 No.26 シャッフルゲーム
ユーザー CroweaCrowea
提出日時 2019-02-04 13:54:54
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 765 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 69,508 KB
実行使用メモリ 23,732 KB
最終ジャッジ日時 2023-08-26 07:38:06
合計ジャッジ時間 3,139 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
23,652 KB
testcase_01 AC 56 ms
21,684 KB
testcase_02 AC 56 ms
21,712 KB
testcase_03 AC 57 ms
23,732 KB
testcase_04 AC 58 ms
21,788 KB
testcase_05 AC 57 ms
19,636 KB
testcase_06 AC 58 ms
21,816 KB
testcase_07 AC 57 ms
23,664 KB
testcase_08 AC 53 ms
21,736 KB
testcase_09 AC 54 ms
21,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Program
{
    static void Swap<T>(ref T lhs, ref T rhs)
    {
        T temp;
        temp = lhs;
        lhs = rhs;
        rhs = temp;
    }

    public static void Main(string[] args)
    {
        var initPos = int.Parse(Console.ReadLine()) - 1;
        var swapTimes = int.Parse(Console.ReadLine());
        var nums = new int[]{ 1, 2, 3 };
        var correct = nums[initPos];

        int[] poses;
        for (var i = 0; i < swapTimes; i++)
        {
            poses = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Swap(ref nums[poses[0]-1], ref nums[poses[1]-1]);
        }
        Console.WriteLine(Array.IndexOf(nums, correct)+1);
    }
}
0