結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | fgwiebfaoish |
提出日時 | 2020-05-29 21:54:50 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 905 ms / 2,000 ms |
コード長 | 5,727 bytes |
コンパイル時間 | 1,648 ms |
コンパイル使用メモリ | 109,952 KB |
実行使用メモリ | 65,248 KB |
最終ジャッジ日時 | 2024-04-23 21:54:21 |
合計ジャッジ時間 | 18,350 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
18,688 KB |
testcase_01 | AC | 24 ms
18,688 KB |
testcase_02 | AC | 445 ms
44,908 KB |
testcase_03 | AC | 589 ms
63,468 KB |
testcase_04 | AC | 572 ms
63,464 KB |
testcase_05 | AC | 515 ms
64,320 KB |
testcase_06 | AC | 424 ms
64,328 KB |
testcase_07 | AC | 153 ms
33,652 KB |
testcase_08 | AC | 534 ms
65,004 KB |
testcase_09 | AC | 67 ms
26,496 KB |
testcase_10 | AC | 249 ms
41,464 KB |
testcase_11 | AC | 176 ms
35,316 KB |
testcase_12 | AC | 131 ms
33,152 KB |
testcase_13 | AC | 446 ms
48,888 KB |
testcase_14 | AC | 529 ms
55,528 KB |
testcase_15 | AC | 635 ms
59,852 KB |
testcase_16 | AC | 289 ms
40,320 KB |
testcase_17 | AC | 695 ms
59,604 KB |
testcase_18 | AC | 208 ms
35,840 KB |
testcase_19 | AC | 659 ms
61,804 KB |
testcase_20 | AC | 173 ms
32,768 KB |
testcase_21 | AC | 252 ms
39,808 KB |
testcase_22 | AC | 571 ms
57,724 KB |
testcase_23 | AC | 30 ms
20,992 KB |
testcase_24 | AC | 33 ms
21,632 KB |
testcase_25 | AC | 122 ms
32,256 KB |
testcase_26 | AC | 331 ms
42,104 KB |
testcase_27 | AC | 323 ms
41,252 KB |
testcase_28 | AC | 564 ms
57,852 KB |
testcase_29 | AC | 83 ms
28,416 KB |
testcase_30 | AC | 645 ms
59,612 KB |
testcase_31 | AC | 431 ms
49,900 KB |
testcase_32 | AC | 274 ms
39,424 KB |
testcase_33 | AC | 643 ms
60,732 KB |
testcase_34 | AC | 211 ms
35,684 KB |
testcase_35 | AC | 646 ms
60,224 KB |
testcase_36 | AC | 28 ms
19,712 KB |
testcase_37 | AC | 30 ms
20,864 KB |
testcase_38 | AC | 28 ms
20,096 KB |
testcase_39 | AC | 30 ms
20,608 KB |
testcase_40 | AC | 26 ms
19,328 KB |
testcase_41 | AC | 905 ms
65,248 KB |
testcase_42 | AC | 237 ms
35,828 KB |
testcase_43 | AC | 437 ms
45,300 KB |
testcase_44 | AC | 144 ms
30,816 KB |
testcase_45 | AC | 410 ms
44,660 KB |
testcase_46 | AC | 23 ms
17,920 KB |
testcase_47 | AC | 24 ms
18,560 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using static Exg; static class Program{ const int mod=(int)1e9+7; const long inf=long.MaxValue-1; static List<Tuple<int,double>>[] li; static bool[] b; static void Main(){ Sc sc=new Sc(); var s=sc.Ia; var g=sc.Ia; int n=s[0],m=s[1]; var pa=new Pair[n+1]; for(int i = 1;i<=n;i++) { pa[i]=new Pair(sc.Da); } li=new List<Tuple<int,double>>[n+1]; b=new bool[n+1]; var c=new double[n+1]; for(int i=1;i<=n;i++){ li[i]=new List<Tuple<int,double>>(); c[i]=inf; } for(int i=0;i<m;i++){ var e=sc.Ia; var d=Gp0(pa[e[0]],pa[e[1]]); li[e[0]].Add(Tuple.Create(e[1],d)); li[e[1]].Add(Tuple.Create(e[0],d)); } var pq=new Pq<Dt<int>>(32,true); pq.Push(new Dt<int>(0,g[0])); while(pq.cnt>0){ var e=pq.Top; pq.Pop(); if(b[e.d]){continue;} b[e.d]=true; for(int i=0;i<li[e.d].Count;i++){ if(!b[li[e.d][i].Item1]&&c[li[e.d][i].Item1]>li[e.d][i].Item2+e.n){ pq.Push(new Dt<int>(li[e.d][i].Item2+e.n,li[e.d][i].Item1)); c[li[e.d][i].Item1]=li[e.d][i].Item2+e.n; } } } Console.WriteLine("{0}",c[g[1]]); } static void Fu(int a,int g){ b[a]=true; for(int i=0;i<li[a].Count;i++){ if(!b[li[a][i].Item1]){Fu(li[a][i].Item1,g);} } } } public struct Pair{ public double x,y; public Pair(double x,double y){this.x=x;this.y=y;} public Pair(double[] da){x=da[0];y=da[1];} public Pair(Pair p){x=p.x;y=p.y;} public override string ToString()=>x.ToString()+" "+y.ToString(); public static Pair operator+(Pair a,Pair b){a.x+=b.x;a.y+=b.y;return a;} public static Pair operator-(Pair a,Pair b){a.x-=b.x;a.y-=b.y;return a;} public static Pair operator*(Pair a,double n){a.x*=n;a.y*=n;return a;} public static Pair operator/(Pair a,double n){a.x/=n;a.y/=n;return a;} public static bool operator==(Pair a,Pair b){return a.x==b.x&&a.y==b.y;} public static bool operator!=(Pair a,Pair b){return a.x!=b.x||a.y!=b.y;} public override bool Equals(object obj){return false;} public override int GetHashCode(){return 0;} } static class Exg{ static public double Gp0(Pair a,Pair b){return Sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));} } public class Dt<T>:IComparable{ public double n; public T d; public Dt(double n,T d){this.n=n;this.d=d;} public int CompareTo(object obj){ Dt<T> mymo=(Dt<T>)obj; if(mymo.n>n){return -1;} else if(mymo.n<n){return 1;} else{return 0;} } } public class Pq<T> where T:IComparable{ private T[] he; public int cnt=0,max=0; private Func<T,T,int> compare; public Pq(int max,bool mm){ this.max=max; he=new T[max]; if(mm){compare=Ao;} else{compare=Do;} } public void Push(T x){ if(cnt==max){Extend();} int j=cnt; while(j!=0&&compare(x,he[(j-1)>>1])>0){he[j]=he[(j-1)>>1];j=(j-1)>>1;} he[j]=x; cnt++; } public void Pop(){ cnt--; T r=he[cnt]; int j=0; while(true){ if(j*2+1<cnt){ if(compare(he[j*2+1],he[j*2+2])>0){j=j*2+1;} else{j=j*2+2;} } else if(j*2<cnt){j=j*2+1;} else{break;} if(compare(he[j],r)<=0){j=(j-1)>>1;break;} he[(j-1)>>1]=he[j]; } he[j]=r; } private int Ao(T x,T y){return y.CompareTo(x);} private int Do(T x,T y){return x.CompareTo(y);} public T Top{get{return he[0];}} private void Extend(){ T[] nhe=new T[max<<1]; Array.Copy(he,nhe,max); he=nhe; max<<=1; } } public class Sc{ public int I{get{return int.Parse(Console.ReadLine());}} public long L{get{return long.Parse(Console.ReadLine());}} public double D{get{return double.Parse(Console.ReadLine());}} public string S{get{return Console.ReadLine();}} public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}} public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}} public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}} public string[] Sa{get{return Console.ReadLine().Split();}} public object[] Oa{get{return Console.ReadLine().Split();}} public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}} public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);} public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);} public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}} public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);} public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);} public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}} public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);} public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);} public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;} public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;} public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;} public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;} }