結果

問題 No.1370 置換門松列
ユーザー さかぽんさかぽん
提出日時 2021-02-18 13:06:37
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 933 bytes
コンパイル時間 2,020 ms
コンパイル使用メモリ 112,832 KB
実行使用メモリ 46,468 KB
最終ジャッジ日時 2024-04-25 17:07:04
合計ジャッジ時間 4,428 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
25,320 KB
testcase_01 AC 26 ms
24,640 KB
testcase_02 AC 27 ms
24,516 KB
testcase_03 AC 31 ms
27,496 KB
testcase_04 AC 27 ms
26,592 KB
testcase_05 AC 32 ms
27,248 KB
testcase_06 AC 27 ms
24,388 KB
testcase_07 AC 32 ms
27,368 KB
testcase_08 AC 31 ms
27,316 KB
testcase_09 AC 27 ms
25,012 KB
testcase_10 AC 32 ms
27,328 KB
testcase_11 AC 27 ms
24,772 KB
testcase_12 AC 27 ms
24,624 KB
testcase_13 AC 27 ms
24,768 KB
testcase_14 AC 27 ms
24,808 KB
testcase_15 WA -
testcase_16 AC 27 ms
26,724 KB
testcase_17 AC 27 ms
24,772 KB
testcase_18 AC 27 ms
24,876 KB
testcase_19 AC 29 ms
24,796 KB
testcase_20 AC 27 ms
22,452 KB
testcase_21 AC 97 ms
42,016 KB
testcase_22 AC 61 ms
29,272 KB
testcase_23 AC 88 ms
41,168 KB
testcase_24 AC 54 ms
31,584 KB
testcase_25 AC 97 ms
42,000 KB
testcase_26 AC 98 ms
46,468 KB
testcase_27 AC 58 ms
30,628 KB
testcase_28 AC 61 ms
32,580 KB
testcase_29 AC 58 ms
32,180 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

class E
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
	static void Main() => Console.WriteLine(Solve());
	static object Solve()
	{
		var (n, m) = Read2();
		var a = Read();

		var x = new int[m + 1];
		int c = 1 << 20, t = 1;

		if (a[0] == a[1]) return "No";
		x[a[0]] = c;
		x[a[1]] = c + t++;

		for (int i = 2; i < n; i++)
		{
			if (x[a[i]] == 0)
			{
				if (x[a[i - 2]] < x[a[i - 1]])
					x[a[i]] = c - t++;
				else
					x[a[i]] = c + t++;
			}
			else
			{
				if (!IsKadomatsu(x, a, i - 2)) return "No";
			}
		}

		return "Yes\n" + string.Join(" ", x.Skip(1).Select(v => v == 0 ? 1 : v));
	}

	static bool IsKadomatsu(int[] x, int[] a, int i) => x[a[i]] != x[a[i + 2]] && (x[a[i]] < x[a[i + 1]] && x[a[i + 1]] > x[a[i + 2]] || x[a[i]] > x[a[i + 1]] && x[a[i + 1]] < x[a[i + 2]]);
}
0