結果
問題 | No.429 CupShuffle |
ユーザー | 14番 |
提出日時 | 2016-11-08 11:04:05 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 190 ms / 2,000 ms |
コード長 | 2,326 bytes |
コンパイル時間 | 2,549 ms |
コンパイル使用メモリ | 106,136 KB |
実行使用メモリ | 36,828 KB |
最終ジャッジ日時 | 2023-08-16 14:51:05 |
合計ジャッジ時間 | 5,102 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 66 ms
24,064 KB |
testcase_01 | AC | 63 ms
21,848 KB |
testcase_02 | AC | 64 ms
23,920 KB |
testcase_03 | AC | 62 ms
21,860 KB |
testcase_04 | AC | 64 ms
21,828 KB |
testcase_05 | AC | 63 ms
21,868 KB |
testcase_06 | AC | 64 ms
23,804 KB |
testcase_07 | AC | 66 ms
21,716 KB |
testcase_08 | AC | 65 ms
23,828 KB |
testcase_09 | AC | 65 ms
22,024 KB |
testcase_10 | AC | 82 ms
26,616 KB |
testcase_11 | AC | 190 ms
36,828 KB |
testcase_12 | AC | 182 ms
34,340 KB |
testcase_13 | AC | 186 ms
35,988 KB |
testcase_14 | AC | 183 ms
30,508 KB |
testcase_15 | AC | 64 ms
21,948 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using System.Collections.Generic; public class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.ReadLine().Trim().Split(' ').Select(a=>int.Parse(a)).ToArray(); int cupCount = inpt[0]; int swapCount = inpt[1]; int target = inpt[2] - 1; int[] tyokuzen = new int[cupCount]; for(int i=0; i<cupCount; i++) { tyokuzen[i] = i+1; } for(int i=0; i<target; i++) { inpt = Reader.ReadLine().Trim() .Split(' ').Select(a=>int.Parse(a)-1).ToArray(); this.Swap(tyokuzen, inpt[0], inpt[1]); } Reader.ReadLine(); List<int[]> swList = new List<int[]>(); for(int i=target+1; i<swapCount; i++) { swList.Add(Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)-1).ToArray()); } string[] inptstr = Reader.ReadLine().Trim().Split(' '); int[] tyokugo = new int[inptstr.Length]; for(int i=0;i<inptstr.Length; i++) { tyokugo[i] = int.Parse(inptstr[i]); } for(int i=swList.Count-1; i>=0;i--) { Swap(tyokugo, swList[i][0], swList[i][1]); } List<int> ans = new List<int>(); for(int i=0; i<tyokuzen.Length; i++) { if(tyokuzen[i] != tyokugo[i]) { ans.Add(i+1); if(ans.Count >= 2) { break; } } } Console.WriteLine(string.Join(" ", ans)); } private void Swap(int[] arr, int idx1, int idx2) { int num = arr[idx1]; arr[idx1] = arr[idx2]; arr[idx2] = num; } public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }