結果
問題 |
No.26 シャッフルゲーム
|
ユーザー |
|
提出日時 | 2019-02-04 13:54:54 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 34 ms / 5,000 ms |
コード長 | 765 bytes |
コンパイル時間 | 4,835 ms |
コンパイル使用メモリ | 105,856 KB |
実行使用メモリ | 19,072 KB |
最終ジャッジ日時 | 2024-12-25 00:09:28 |
合計ジャッジ時間 | 5,911 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
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; 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); } }