結果

問題 No.1170 Never Want to Walk
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-07-26 10:25:45
言語 C#
(.NET 8.0.203)
結果
TLE  
実行時間 -
コード長 1,470 bytes
コンパイル時間 17,343 ms
コンパイル使用メモリ 169,308 KB
実行使用メモリ 453,732 KB
最終ジャッジ日時 2024-04-12 11:01:02
合計ジャッジ時間 20,477 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
32,896 KB
testcase_01 AC 53 ms
36,624 KB
testcase_02 AC 53 ms
29,440 KB
testcase_03 AC 54 ms
29,696 KB
testcase_04 AC 54 ms
29,440 KB
testcase_05 AC 53 ms
29,676 KB
testcase_06 AC 53 ms
29,436 KB
testcase_07 AC 54 ms
29,332 KB
testcase_08 AC 53 ms
29,440 KB
testcase_09 AC 53 ms
29,440 KB
testcase_10 AC 54 ms
29,696 KB
testcase_11 AC 53 ms
29,696 KB
testcase_12 AC 71 ms
31,104 KB
testcase_13 AC 1,357 ms
147,280 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (139 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

namespace yukicoder
{
	public class Program
	{
		public static void Main()
		{
			var line = Console.ReadLine().Split(' ');
			var n = int.Parse(line[0]);
			var a = int.Parse(line[1]);
			var b = int.Parse(line[2]);
			line = Console.ReadLine().Split(' ');
			int i, j;
			var x = new int[n];
			var c = new int[n];
			for (i = 0; i < n; i++)
			{
				x[i] = int.Parse(line[i]);
				c[i] = -1;
			}
            for (i = 0; i < n; i++)
            {
                if (c[i] == -1)
                {
					var q = new Queue<int>();
					q.Enqueue(i);
                    while (q.Count > 0)
                    {
						var m = q.Dequeue();
						c[m] = i;
                        for (j = 1; m + j < n && Math.Abs(x[m + j] - x[m]) <= b; j++)
                        {
							if (Math.Abs(x[m + j] - x[m]) >= a && c[m + j] == -1)
                            {
								q.Enqueue(m + j);
                            }
						}
						for (j = 1; m - j > 0 && Math.Abs(x[m - j] - x[m]) <= b; j++)
						{
							if (Math.Abs(x[m - j] - x[m]) >= a && c[m - j] == -1)
							{
								q.Enqueue(m - j);
							}
						}
					}
				}
            }
			foreach(var z in c)
            {
				var sum = 0;
                for (i = 0; i < n; i++)
                {
                    if (z == c[i])
                    {
						sum++;
                    }
                }
				Console.WriteLine(sum);
			}
		}
	}
}
0