結果
| 問題 |
No.429 CupShuffle
|
| コンテスト | |
| ユーザー |
No
|
| 提出日時 | 2017-05-27 21:58:50 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 158 ms / 2,000 ms |
| コード長 | 1,929 bytes |
| コンパイル時間 | 800 ms |
| コンパイル使用メモリ | 106,496 KB |
| 実行使用メモリ | 39,680 KB |
| 最終ジャッジ日時 | 2024-09-21 14:35:08 |
| 合計ジャッジ時間 | 2,952 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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.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);
}
}
}
}
No