結果
| 問題 | No.26 シャッフルゲーム |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-02-04 13:54:54 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 5,000 ms |
| コード長 | 765 bytes |
| 記録 | |
| コンパイル時間 | 3,255 ms |
| コンパイル使用メモリ | 107,088 KB |
| 実行使用メモリ | 19,968 KB |
| 最終ジャッジ日時 | 2026-05-30 17:20:12 |
| 合計ジャッジ時間 | 4,546 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
}
}