結果
問題 |
No.1170 Never Want to Walk
|
ユーザー |
|
提出日時 | 2023-07-20 10:18:05 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,319 bytes |
コンパイル時間 | 20,169 ms |
コンパイル使用メモリ | 168,480 KB |
実行使用メモリ | 61,696 KB |
最終ジャッジ日時 | 2024-09-20 07:03:17 |
合計ジャッジ時間 | 15,951 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 WA * 1 TLE * 1 -- * 25 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (136 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) /home/judge/data/code/Main.cs(11,13): warning CS0168: 変数 'l' は宣言されていますが、使用されていません [/home/judge/data/code/main.csproj] main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using System.Collections.Generic; using System.Linq; 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,k,l; var x = new int[n]; for(i=0;i<n;i++){ x[i] = int.Parse(line[i]); } var s = new List<List <int>>(); for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ k = Math.Abs(x[i]-x[j]); if(k>=a&&k<=b){ var t = new List<int>{x[i],x[j]}; s.Add(t); } } } var u = new List<List<int>>(); for(i=0;i<s.Count-1;i++){ for(j=i+1;j<s.Count;j++){ if(s[i].Any(value => value == s[j][0]||value == s[j][1])){ s[i].AddRange(s[j]); u.Add(s[j]); } } } for(i=0;i<u.Count;i++){ s.Remove(u[i]); } for(i=0;i<n;i++){ var c = true; for(j=0;j<s.Count;j++){ if(s[j].Any(value => value == x[i])){ IEnumerable<int> r = s[j].Distinct(); var num = new List<int>(r); Console.WriteLine(num.Count); c = false; break; } } if(c){ Console.WriteLine(1); } } } }