結果
| 問題 | No.326 あみだますたー |
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2026-06-20 19:53:54 |
| 言語 | C# (.NET 10.0.201) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,072 bytes |
| 記録 | |
| コンパイル時間 | 6,989 ms |
| コンパイル使用メモリ | 173,176 KB |
| 実行使用メモリ | 197,192 KB |
| 最終ジャッジ日時 | 2026-06-20 19:54:12 |
| 合計ジャッジ時間 | 13,409 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 3 WA * 22 MLE * 1 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (89 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
// https://yukicoder.me/problems/no/326
// yukicoder 326 あみだますたー
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("5");
WillReturn.Add("6");
WillReturn.Add("1 2");
WillReturn.Add("3 4");
WillReturn.Add("2 3");
WillReturn.Add("3 4");
WillReturn.Add("1 2");
WillReturn.Add("4 5");
WillReturn.Add("5 1 4 3 2");
}
else if (InputPattern == "Input2") {
WillReturn.Add("6");
WillReturn.Add("4");
WillReturn.Add("1 2");
WillReturn.Add("2 3");
WillReturn.Add("5 6");
WillReturn.Add("3 4");
WillReturn.Add("2 6 3 1 5 4");
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static long[] GetSplitArr(string pStr)
{
return (pStr == "" ? new string[0] : pStr.Split(' ')).Select(pX => long.Parse(pX)).ToArray();
}
static void Main()
{
List<string> InputList = GetInputList();
long[] wkArr = { };
Action<string> SplitAct = (pStr) => wkArr = GetSplitArr(pStr);
long N = long.Parse(InputList[0]);
long K = long.Parse(InputList[1]);
long[] AArr = GetSplitArr(InputList[InputList.Count - 1]);
var GoalDict = new Dictionary<long, long>();
for (long I = 0; I <= AArr.GetUpperBound(0); I++) {
GoalDict[AArr[I]] = I + 1;
}
var CurrDict = new Dictionary<long, long>();
for (long I = 1; I <= N; I++) {
CurrDict[I] = I;
}
foreach (string EachStr in InputList.Skip(2).Take((int)K)) {
SplitAct(EachStr);
long L = wkArr[0];
long R = wkArr[1];
long tmp = CurrDict[L];
CurrDict[L] = CurrDict[R];
CurrDict[R] = tmp;
}
var AnswerList = new List<long>();
for (long I = 1; I <= N; I++) {
long SearchVal = GoalDict[I];
long StaInd = 0;
for (long J = I + 1; J <= N; J++) {
if (CurrDict[J] == SearchVal) {
StaInd = J;
break;
}
}
// 既にゴールにいる場合
if (I == StaInd) continue;
for (long J = StaInd; I + 1 <= J; J--) {
// 三角交換
long tmp = CurrDict[J];
CurrDict[J] = CurrDict[J - 1];
CurrDict[J - 1] = tmp;
//AnswerList.Add(J - 1);
}
}
Console.WriteLine(AnswerList.Count);
foreach (long EachL in AnswerList) {
Console.WriteLine("{0} {1}", EachL, EachL + 1);
}
}
}
aketijyuuzou