結果

問題 No.429 CupShuffle
ユーザー NoNo
提出日時 2017-05-27 21:58:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 1,929 bytes
コンパイル時間 927 ms
コンパイル使用メモリ 111,088 KB
実行使用メモリ 45,248 KB
最終ジャッジ日時 2023-10-21 13:21:08
合計ジャッジ時間 3,485 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
25,400 KB
testcase_01 AC 28 ms
25,404 KB
testcase_02 AC 28 ms
25,404 KB
testcase_03 AC 28 ms
25,404 KB
testcase_04 AC 29 ms
25,400 KB
testcase_05 AC 28 ms
25,404 KB
testcase_06 AC 29 ms
25,400 KB
testcase_07 AC 29 ms
25,400 KB
testcase_08 AC 29 ms
25,404 KB
testcase_09 AC 30 ms
25,400 KB
testcase_10 AC 44 ms
26,304 KB
testcase_11 AC 163 ms
42,684 KB
testcase_12 AC 154 ms
41,800 KB
testcase_13 AC 166 ms
45,248 KB
testcase_14 AC 149 ms
34,048 KB
testcase_15 AC 28 ms
25,404 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.Linq;
namespace Yuki
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int k = int.Parse(ss[1]);
            int x = int.Parse(ss[2]);

            var c = new int[n];
            for (int i = 1; i <= n; i++)
            {
                c[i - 1] = i;
            }

            for (int i = 0; i < x - 1; i++)
            {
                ss = Console.ReadLine().Split();
                int a = int.Parse(ss[0]) - 1;
                int b = int.Parse(ss[1]) - 1;
                int w = c[a];
                c[a] = c[b];
                c[b] = w;
            }

            Console.ReadLine();

            string[][] f = new string[k - x][];
            for (int i = 0; i < k - x; i++)
            {
                f[i] = Console.ReadLine().Split();
            }

            string[] s = Console.ReadLine().Split();
            int[] c2 = s.Select(z => int.Parse(z)).ToArray();

            for (int i = k - x - 1; i >= 0; i--)
            {
                int a = int.Parse(f[i][0]) - 1;
                int b = int.Parse(f[i][1]) - 1;
                int w = c2[a];
                c2[a] = c2[b];
                c2[b] = w;
            }

            int a1 = -1;
            int a2 = -1;
            for (int i = 0; i < n; i++)
            {
                if (c[i] != c2[i])
                {
                    if (a1 == -1)
                    {
                        a1 = i + 1;
                        continue;
                    }
                    a2 = i + 1;
                    break;

                }
            }

            if (a1 > a2)
            {
                Console.WriteLine("{0} {1}", a2, a1);
            }
            else
            {
                Console.WriteLine("{0} {1}", a1, a2);
            }
        }
    }
}
0