結果

問題 No.429 CupShuffle
ユーザー jousenjousen
提出日時 2016-10-02 23:45:27
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 1,600 bytes
コンパイル時間 4,937 ms
コンパイル使用メモリ 107,888 KB
実行使用メモリ 37,804 KB
最終ジャッジ日時 2023-08-13 18:18:44
合計ジャッジ時間 7,332 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
21,788 KB
testcase_01 AC 62 ms
23,844 KB
testcase_02 AC 62 ms
22,008 KB
testcase_03 AC 62 ms
22,000 KB
testcase_04 AC 63 ms
21,848 KB
testcase_05 AC 62 ms
21,884 KB
testcase_06 AC 63 ms
23,996 KB
testcase_07 AC 63 ms
21,784 KB
testcase_08 AC 61 ms
21,972 KB
testcase_09 AC 63 ms
23,888 KB
testcase_10 AC 81 ms
24,748 KB
testcase_11 AC 188 ms
35,032 KB
testcase_12 AC 187 ms
37,804 KB
testcase_13 AC 189 ms
35,052 KB
testcase_14 AC 190 ms
34,912 KB
testcase_15 AC 62 ms
23,924 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.Collections.Generic;
using System.Collections;
using System.Linq;


namespace tes
{
	class contest
	{
		static void Main(string[] args)
		{
			 
           var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = input[0];
            int K = input[1];
            int X = input[2];
            var change = new Tuple<int, int>[K];
            var last = new int[N];

            for(int i =0; i < K; i++)
            {
                var tmp = Console.ReadLine().Split(' ').Select(c=>c).ToArray();
                if (tmp[0] == "?") continue;
                change[i] = new Tuple<int, int>(int.Parse(tmp[0]), int.Parse(tmp[1]));
            }
            last = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var start = Enumerable.Range(1,N).ToArray();

            for(int i =0; i<X-1; i++)
            {
                int l = change[i].Item1-1;
                int r = change[i].Item2-1;

                int tmp = start[l];
                start[l] = start[r];
                start[r] = tmp;
            }


            for(int i =0; i<K- X; i++)
            {
                int l = change[K-i-1].Item1 - 1;
                int r = change[K-i-1].Item2 - 1;

                int tmp = last[l];
                last[l] = last[r];
                last[r] = tmp;
            }

            var ans = new List<int>();

            for(int i =0; i< N; i++)
            {
                if (start[i] != last[i]) ans.Add(i+1);
            }

            Console.WriteLine(string.Join(" ", ans));
		}				 
	}
}
0