結果
問題 | No.429 CupShuffle |
ユーザー |
![]() |
提出日時 | 2016-10-13 04:52:01 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 170 ms / 2,000 ms |
コード長 | 1,885 bytes |
コンパイル時間 | 1,974 ms |
コンパイル使用メモリ | 109,620 KB |
実行使用メモリ | 35,584 KB |
最終ジャッジ日時 | 2024-11-22 02:33:56 |
合計ジャッジ時間 | 3,857 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
コンパイルメッセージ
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;namespace Yukicoder{class Program{static void Main(string[] args){var s = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();int N = s[0];int K = s[1];int X = s[2];List<int> before = new List<int>();List<int> after = new List<int>();List<int[]> swapList = new List<int[]>();for (int i = 0; i < N; i++){before.Add(i + 1);}for (int j = 0; j < K; j++){if (j == X - 1){Console.ReadLine(); //Xint[] tmp = { 0, 0 };swapList.Add(tmp);continue;}var index = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();swapList.Add(index);}after.AddRange(Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray());for (int i = 0; i < X - 1; i++){Swap(swapList[i][0] - 1, swapList[i][1] - 1, before);}for (int i = K - 1; i >= X; i--){Swap(swapList[i][0] - 1, swapList[i][1] - 1, after);}List<int> result = new List<int>();for (int i = 0; i < N; i++){if (before[i] != after[i]){result.Add(i + 1);}}Console.WriteLine(result[0] + " " + result[1]);}static void Swap(int a, int b, List<int> list){int tmp;tmp = list[a];list[a] = list[b];list[b] = tmp;}}}