結果
| 問題 | No.326 あみだますたー |
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2026-06-20 19:57:07 |
| 言語 | C# (.NET 10.0.201) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,281 bytes |
| 記録 | |
| コンパイル時間 | 8,773 ms |
| コンパイル使用メモリ | 175,692 KB |
| 実行使用メモリ | 200,448 KB |
| 最終ジャッジ日時 | 2026-06-20 19:57:26 |
| 合計ジャッジ時間 | 14,047 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 3 WA * 22 MLE * 1 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (94 ミリ秒)。 /home/judge/data/code/Main.cs(9,19): warning CS0414: フィールド 'Program.InputPattern' が割り当てられていますが、値は使用されていません [/home/judge/data/code/main.csproj] 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 IEnumerable<string> GetInputList()
{
string wkStr;
while ((wkStr = Console.ReadLine()) != null) yield return wkStr;
}
static int[] GetSplitArr(string pStr)
{
return (pStr == "" ? new string[0] : pStr.Split(' ')).Select(pX => int.Parse(pX)).ToArray();
}
static void Main()
{
string[] InputList = GetInputList().ToArray();
int[] wkArr = { };
Action<string> SplitAct = (pStr) => wkArr = GetSplitArr(pStr);
int N = int.Parse(InputList[0]);
int K = int.Parse(InputList[1]);
int[] AArr = GetSplitArr(InputList[InputList.Length - 1]);
var GoalDict = new Dictionary<int, int>();
for (int I = 0; I <= AArr.GetUpperBound(0); I++) {
GoalDict[AArr[I]] = I + 1;
}
var CurrDict = new Dictionary<int, int>();
for (int I = 1; I <= N; I++) {
CurrDict[I] = I;
}
foreach (string EachStr in InputList.Skip(2).Take((int)K)) {
SplitAct(EachStr);
int L = wkArr[0];
int R = wkArr[1];
int tmp = CurrDict[L];
CurrDict[L] = CurrDict[R];
CurrDict[R] = tmp;
}
var AnswerList = new List<int>();
for (int I = 1; I <= N; I++) {
int SearchVal = GoalDict[I];
int StaInd = 0;
for (int J = I + 1; J <= N; J++) {
if (CurrDict[J] == SearchVal) {
StaInd = J;
break;
}
}
// 既にゴールにいる場合
if (I == StaInd) continue;
for (int J = StaInd; I + 1 <= J; J--) {
// 三角交換
int tmp = CurrDict[J];
CurrDict[J] = CurrDict[J - 1];
CurrDict[J - 1] = tmp;
//AnswerList.Add(J - 1);
}
}
Console.WriteLine(AnswerList.Count);
foreach (int EachL in AnswerList) {
Console.WriteLine("{0} {1}", EachL, EachL + 1);
}
}
}
aketijyuuzou