結果

問題 No.26 シャッフルゲーム
ユーザー n.yn.y
提出日時 2022-06-08 16:25:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 1,158 bytes
コンパイル時間 831 ms
コンパイル使用メモリ 108,632 KB
実行使用メモリ 24,148 KB
最終ジャッジ日時 2023-10-21 04:07:32
合計ジャッジ時間 1,712 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
24,148 KB
testcase_01 AC 26 ms
24,148 KB
testcase_02 AC 26 ms
24,148 KB
testcase_03 AC 26 ms
24,148 KB
testcase_04 AC 26 ms
24,148 KB
testcase_05 AC 26 ms
24,148 KB
testcase_06 AC 25 ms
24,148 KB
testcase_07 AC 26 ms
24,148 KB
testcase_08 AC 25 ms
24,148 KB
testcase_09 AC 25 ms
24,148 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.Diagnostics;

namespace yukicoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //印が付いたカップの位置
            int N = int.Parse(Console.ReadLine());
            //カップを入れ替える回数
            int M = int.Parse(Console.ReadLine());


            //現在の印の位置
            string x = N.ToString();
            //入れ替える回数分ループ
            for (int i = 0; i < M; i++)
            {

                string[] str = Console.ReadLine().Split(' ');
                //入れ替える位置の番号
                for (int j = 0; j < 2; j++)
                {

                    int.Parse(str[j]);
                    

                }

                //xと入れ替える位置が同じなら
                if (x == str[0])
                {
                            //入れ替える
                            x = str[1];
                }
                else if(x==str[1])
                {
                            x = str[0];

                }
            }
            Console.WriteLine(x);
        }
    }
}
0