結果
問題 | No.1041 直線大学 |
ユーザー | fgwiebfaoish |
提出日時 | 2022-04-17 22:21:36 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 14,599 bytes |
コンパイル時間 | 3,633 ms |
コンパイル使用メモリ | 114,048 KB |
実行使用メモリ | 19,584 KB |
最終ジャッジ日時 | 2024-11-16 08:14:07 |
合計ジャッジ時間 | 3,896 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
18,176 KB |
testcase_01 | AC | 24 ms
18,432 KB |
testcase_02 | AC | 26 ms
18,432 KB |
testcase_03 | AC | 24 ms
18,304 KB |
testcase_04 | AC | 24 ms
18,432 KB |
testcase_05 | AC | 23 ms
18,304 KB |
testcase_06 | AC | 24 ms
18,432 KB |
testcase_07 | AC | 26 ms
18,688 KB |
testcase_08 | AC | 24 ms
18,560 KB |
testcase_09 | AC | 25 ms
18,560 KB |
testcase_10 | AC | 28 ms
19,200 KB |
testcase_11 | AC | 27 ms
19,584 KB |
testcase_12 | AC | 28 ms
19,456 KB |
testcase_13 | AC | 25 ms
18,688 KB |
testcase_14 | AC | 28 ms
19,268 KB |
testcase_15 | AC | 27 ms
18,560 KB |
testcase_16 | AC | 29 ms
18,880 KB |
testcase_17 | AC | 26 ms
18,688 KB |
testcase_18 | AC | 28 ms
18,944 KB |
testcase_19 | AC | 28 ms
19,008 KB |
testcase_20 | AC | 23 ms
18,432 KB |
testcase_21 | AC | 26 ms
18,688 KB |
testcase_22 | AC | 26 ms
17,920 KB |
testcase_23 | AC | 29 ms
19,412 KB |
testcase_24 | AC | 27 ms
18,688 KB |
testcase_25 | AC | 25 ms
18,816 KB |
testcase_26 | AC | 24 ms
18,688 KB |
testcase_27 | AC | 25 ms
18,432 KB |
testcase_28 | AC | 23 ms
18,304 KB |
testcase_29 | AC | 24 ms
18,432 KB |
testcase_30 | AC | 23 ms
18,432 KB |
testcase_31 | AC | 25 ms
18,560 KB |
testcase_32 | AC | 24 ms
18,176 KB |
testcase_33 | AC | 25 ms
18,304 KB |
testcase_34 | AC | 25 ms
18,176 KB |
testcase_35 | AC | 23 ms
18,432 KB |
testcase_36 | AC | 24 ms
18,304 KB |
testcase_37 | AC | 24 ms
18,432 KB |
testcase_38 | AC | 30 ms
19,268 KB |
testcase_39 | AC | 26 ms
18,688 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; using System.Runtime.CompilerServices; static class Program{ const int mod=(int)1e9+7; const double eps=1e-11; static Sc sc=new Sc(); static void Main(){ Pt pt=new Pt(Solve); pt.Sm(); } static void Solve(Pt pt) { var n=sc.I; var pa=new Pair[n]; var hs=new Dictionary<string,int>(); for(int i = 0;i<n;i++) { pa[i]=new Pair(sc.Da); for(int j = i - 1;j >= 0;j--) { var e=Gp98(pa[i],pa[j]); var t=e.a+" "+e.b+" "+e.c; if(hs.ContainsKey(t)){hs[t]++;} else{hs.Add(t,1);} } } int ans=0; foreach(var e in hs){ans=Max(ans,e.Value);} for(int i = 1;;i++) { if((i*(i+1))>>1==ans) { ans=i+1; break; } } pt.Wl(ans); } } public struct Pair{ public double y,x; public Pair(double y,double x){this.y=y;this.x=x;} public Pair(double[] da){y=da[0];x=da[1];} public Pair(Pair p){y=p.y;x=p.x;} public override string ToString()=>string.Format("{0} {1}",y,x); public static Pair operator+(Pair a,Pair b){a.y+=b.y;a.x+=b.x;return a;} public static Pair operator-(Pair a,Pair b){a.y-=b.y;a.x-=b.x;return a;} public static Pair operator*(Pair a,double n){a.y*=n;a.x*=n;return a;} public static Pair operator/(Pair a,double n){a.y/=n;a.x/=n;return a;} public static bool operator==(Pair a,Pair b){return a.y==b.y&&a.x==b.x;} public static bool operator!=(Pair a,Pair b){return a.y!=b.y||a.x!=b.x;} public static implicit operator Pair((double,double) t){return new Pair(t.Item1,t.Item2);} public static implicit operator Pair(int[] a){return new Pair(a[0],a[1]);} 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.y-b.y)*(a.y-b.y)+(a.x-b.x)*(a.x-b.x));} static public (bool b,Pair p) Gp1(Pair p1,Pair p2,Pair p3,Pair p4){ double t1=(p4.x-p3.x)*(p4.y-p1.y)-(p4.y-p3.y)*(p4.x-p1.x); double t2=(p2.y-p1.y)*(p4.x-p1.x)-(p2.x-p1.x)*(p4.y-p1.y); double t3=(p2.y-p1.y)*(p4.x-p3.x)-(p2.x-p1.x)*(p4.y-p3.y); if(t3==0){ if(Abs(Atan2(p2.x-p1.x,p2.y-p1.y))!=Abs(Atan2(p3.x-p1.x,p3.y-p1.y))){return (p1.y==p3.y&&p1.x==p3.x?true:false,p1);} var a=new (Pair,int)[]{(p1,1),(p2,2),(p3,3),(p4,4)}; Array.Sort(a,(d,e)=>{var c=d.Item1.y.CompareTo(e.Item1.x);return c==0?e.Item1.x.CompareTo(d.Item1.x):c;}); return (Abs(a[0].Item2-a[1].Item2)!=1||Abs(a[2].Item2-a[3].Item2)!=1||(a[1].Item1.y==a[2].Item1.y&&a[1].Item1.x==a[2].Item1.x)?true:false,a[1].Item1); } double t4=t1/t3,t5=t2/t3; if(t4<0||t4>1||t5<0||t5>1){return (false,new Pair(0,0));} else{return (true,new Pair(p1.y+t4*(p2.y-p1.y),p1.x+t4*(p2.x-p1.x)));} } static public double Gp2(Pair p1,Pair p2,Pair p0){return Abs((p2.x-p1.x)*p0.y-(p2.y-p1.y)*p0.x+p2.y*p1.x-p1.y*p2.x)/Sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y));} static public double Gp3(Pair p1,Pair p2,Pair p0){return (p1.y-p2.y)*(p0.x-p1.x)+(p1.x-p2.x)*(p1.y-p0.y);} static public double Gp4(Pair a,Pair b,Pair c){ double a1=a.y-b.y,a2=a.x-b.x,c1=c.y-b.y,c2=c.x-b.x; var e=Acos((a1*c1+a2*c2)/Sqrt((a1*a1+a2*a2)*(c1*c1+c2*c2))); return double.IsNaN(e)?0:e; } static public (bool b,Pair p) Gp5(Pair p1,Pair p2,Pair p0){ double ry=p0.y,rx=p0.x; if(p1.y==p2.y){ry=p1.y;} else if(p1.x==p2.x){rx=p1.x;} else{ double m1=(p2.x-p1.x)/(p2.y-p1.y),b1=p1.x-(m1*p1.y),m2=-1.0/m1,b2=p0.x-(m2*p0.y); ry=(b2-b1)/(m1-m2); rx=(b2*m1-b1*m2)/(m1-m2); } return (((p1.y>=ry&&p2.y<=ry)||(p2.y>=ry&&p1.y<=ry))&&((p1.x>=rx&&p2.x<=rx)||(p2.x>=rx&&p1.x<=rx)),new Pair(ry,rx)); } static public Pair Gp6(Pair a,Pair b,Pair c,int n){ double l1=Sqrt((a.y-b.y)*(a.y-b.y)+(a.x-b.x)*(a.x-b.x)); double l2=Sqrt((c.y-b.y)*(c.y-b.y)+(c.x-b.x)*(c.x-b.x)); double ey=(a.y+(b.y+(c.y-b.y)*(l1/l2)))/2,ex=(a.x+(b.x+(c.x-b.x)*(l1/l2)))/2; ey+=(ey-b.y)*n;ex+=(ex-b.x)*n; return new Pair(ey,ex); } static public Pair Gp7(Pair a,double k,double p){return new Pair(a.y+k*Cos(p),a.x+k*Sin(p));} static public bool Gp8(Pair a,Pair b,Pair c){return (c.y-a.y)*(b.x-a.x)==(b.y-a.y)*(c.x-a.x);} static public Pair Gp9(Pair a,Pair b,Pair c){ double d=a.y*a.y+a.x*a.x,e=b.y*b.y+b.x*b.x,f=c.y*c.y+c.x*c.x,g=2*(a.y*(b.x-c.x)+b.y*(c.x-a.x)+c.y*(a.x-b.x)); return new Pair((d*(b.x-c.x)+e*(c.x-a.x)+f*(a.x-b.x))/g,(d*(c.y-b.y)+e*(a.y-c.y)+f*(b.y-a.y))/g); } static public Pair[] Gp10(Pair p0,double r,Pair p1,Pair p2){ double a=p2.x-p1.x,b=p1.y-p2.y; double d=p0.y*-a+p0.x*-b+a*p1.y+b*p1.x; double g=a*a+b*b; double k=g*r*r-d*d; if(k<0){return new Pair[]{};} if(k==0){return new Pair[]{new Pair(a*d/g+p0.y,b*d/g+p0.x)};} k=Sqrt(k); return new Pair[]{new Pair((a*d-b*k)/g+p0.y,(b*d+a*k)/g+p0.x),new Pair((a*d+b*k)/g+p0.y,(b*d-a*k)/g+p0.x)}; } static public Pair[] Gp11(Pair p1,double r1,Pair p2,double r2){ p2-=p1; double a=(p2.y*p2.y+p2.x*p2.x+r1*r1-r2*r2)/2; double g=p2.y*p2.y+p2.x*p2.x; double k=g*r1*r1-a*a; if(k<0){return new Pair[]{};} if(k==0){return new Pair[]{new Pair(p2.y*a/g,p2.x*a/g)+p1};} k=Sqrt(k); return new Pair[]{new Pair((p2.y*a+p2.x*k)/g,(p2.x*a-p2.y*k)/g)+p1,new Pair((p2.y*a-p2.x*k)/g,(p2.x*a+p2.y*k)/g)+p1}; } static Tuple<double,double> Gp12(Pair[] pa){ int n=pa.Length; double sumx=0,sumy=0,sumxy=0,sumx2=0; for(int i = 0;i<n;i++) { sumxy+=pa[i].y*pa[i].x; sumx+=pa[i].y; sumy+=pa[i].x; sumx2+=pa[i].y*pa[i].y; } return Tuple.Create((n*sumxy-sumx*sumy)/(n*sumx2-sumx*sumx),(sumx2*sumy-sumxy*sumx)/(n*sumx2-sumx*sumx)); } static public Pair[] Gp13(Pair a,Pair p1,double r){ a-=p1; double g=a.y*a.y+a.x*a.x,k=Sqrt(g-r*r); return new Pair[]{new Pair(r*(a.y*r+a.x*k)/g,r*(a.x*r-a.y*k)/g)+p1,new Pair(r*(a.y*r-a.x*k)/g,r*(a.x*r+a.y*k)/g)+p1}; } static public double Gp14(Pair a,Pair b,Pair c){ b-=a;c-=a; return Abs(b.y*c.x-b.x*c.y)/2; } static public double Gp15(Pair a,Pair b,Pair c){return Sign((b.y-a.y)*(c.x-a.x)-(c.y-a.y)*(b.x-a.x));} static public double Gp16(Pair[] pa){ double d=0; int n=pa.Length; for(int i = 0;i<n;i++) {d+=Gp14(pa[0],pa[i],pa[(i+1)%n])*Gp15(pa[0],pa[i],pa[(i+1)%n]);} return Abs(d); } static public double Gp17(Pair a,Pair b){return Atan2(b.x-a.x,b.y-a.y);} static public bool Gp18(Pair a,Pair b,Pair c,Pair d){ a-=d;b-=d;c-=d; var ab=Sign(a.y*b.x-a.x*b.y); var bc=Sign(b.y*c.x-b.x*c.y); var ca=Sign(c.y*a.x-c.x*a.y); return ab==bc&&ab==ca; } static public (long a,long b,long c) Gp98(Pair a,Pair b){ long d=(long)(b.x-a.x),e=(long)(a.y-b.y),f=d*(long)a.y+e*(long)a.x,v=1; d=-d;e=-e; if(d==0){v=f==0?e:Gcd(e,f);} else if(e==0){v=f==0?d:Gcd(d,f);} else{ v=Gcd(d,e); if(f!=0){v=Gcd(v,f);} v=Abs(v)*Sign(d); } return (d/v,e/v,f/v); } static long Gcd(long a,long b){ long c=Max(a,b)%(b=Min(a,b)); while(c!=0){a=b%c;b=c;c=a;} return b; } static public (double a,double b,double c) Gp99(Pair a,Pair b){ double d=b.x-a.x,e=a.y-b.y; return (-d,-e,d*a.y+e*a.x); } static public (Pair p,double d)[] Psort(Pair[] pa,Pair p){ var arr=new (Pair,double)[pa.Length]; for(int i = 0;i<pa.Length;i++) {arr[i]=(pa[i],Atan2(pa[i].x-p.x,pa[i].y-p.y)*180/PI+180);} Array.Sort(arr,(u,v)=>u.Item2.CompareTo(v.Item2)); return arr; } static public (Pair p,double d)[] Psort2(Pair[] pa,Pair p){ int n=pa.Length; var arr=new (Pair,double)[n]; for(int i = 0;i<n;i++) {arr[i]=(pa[i],Atan2(pa[i].x-p.x,pa[i].y-p.y)*180/PI+180);} Array.Sort(arr,(u,v)=>u.Item2.CompareTo(v.Item2)); Array.Resize(ref arr,n<<1); for(int i = 0;i<n;i++) {arr[i+n]=(arr[i].Item1,arr[i].Item2+360);} return arr; } } public class Pt{ private StringBuilder sb=new StringBuilder(); public Pt(Action<Pt> f){f(this);} public void W(int s){sb.Append(s);} public void W(long s){sb.Append(s);} public void W(double s){sb.Append(s);} public void W(decimal s){sb.Append(s);} public void W(char s){sb.Append(s);} public void W(string s){sb.Append(s);} public void W(object s){sb.Append(s);} public void W(string f,int s){sb.Append(s.ToString(f));} public void W(string f,long s){sb.Append(s.ToString(f));} public void W(string f,double s){sb.Append(s.ToString(f));} public void W(string f,decimal s){sb.Append(s.ToString(f));} public void Wl(int s){sb.Append(s).Append(Environment.NewLine);} public void Wl(long s){sb.Append(s).Append(Environment.NewLine);} public void Wl(double s){sb.Append(s).Append(Environment.NewLine);} public void Wl(decimal s){sb.Append(s).Append(Environment.NewLine);} public void Wl(char s){sb.Append(s).Append(Environment.NewLine);} public void Wl(string s){sb.Append(s).Append(Environment.NewLine);} public void Wl(object s){sb.Append(s).Append(Environment.NewLine);} public void Wl(string f,int s){sb.Append(s.ToString(f)).Append(Environment.NewLine);} public void Wl(string f,long s){sb.Append(s.ToString(f)).Append(Environment.NewLine);} public void Wl(string f,double s){sb.Append(s.ToString(f)).Append(Environment.NewLine);} public void Wl(string f,decimal s){sb.Append(s.ToString(f)).Append(Environment.NewLine);} public void Wl(int[] s){sb.Append(string.Join(" ",s)).Append(Environment.NewLine);} public void Wl(long[] s){sb.Append(string.Join(" ",s)).Append(Environment.NewLine);} public void Wl(double[] s){sb.Append(string.Join(" ",s)).Append(Environment.NewLine);} public void Wl(string[] s){sb.Append(string.Join(" ",s)).Append(Environment.NewLine);} public void Wl(object[] s){sb.Append(string.Join(" ",s)).Append(Environment.NewLine);} public void Wl(){sb.Append(Environment.NewLine);} public void Sm(){Console.Write(sb);} public static bool operator==(Pt a,Pt b){return a.sb.ToString()==b.sb.ToString();} public static bool operator!=(Pt a,Pt b){return a.sb.ToString()!=b.sb.ToString();} public override bool Equals(object obj){return false;} public override int GetHashCode(){return 0;} } public class Sc{ [MethodImpl(MethodImplOptions.AggressiveInlining)] protected virtual string Rl(){return Console.ReadLine();} [MethodImpl(MethodImplOptions.AggressiveInlining)] protected virtual string[] Sp(string st){return st.Split();} [MethodImpl(MethodImplOptions.AggressiveInlining)] private T Ct<T>(string s){return (T)Convert.ChangeType(s,typeof(T));} public virtual int I{get{return int.Parse(Rl());}} public virtual long L{get{return long.Parse(Rl());}} public virtual double D{get{return double.Parse(Rl());}} public virtual string S{get{return Rl();}} public int[] Ia{get{return Array.ConvertAll(Sp(Rl()),int.Parse);}} public long[] La{get{return Array.ConvertAll(Sp(Rl()),long.Parse);}} public double[] Da{get{return Array.ConvertAll(Sp(Rl()),double.Parse);}} public string[] Sa{get{return Sp(Rl());}} public object[] Oa{get{return Sp(Rl());}} public int[] Ia2{get{return Array.ConvertAll(Sp("0 "+Rl()+" 0"),int.Parse);}} public int[] Ia3(string a,string b){return Array.ConvertAll(Sp(a+Rl()+b),int.Parse);} public int[] Ia3(int a){return Array.ConvertAll(Sp(Rl()+" "+a.ToString()),int.Parse);} public long[] La2{get{return Array.ConvertAll(Sp("0 "+Rl()+" 0"),long.Parse);}} public long[] La3(string a,string b){return Array.ConvertAll(Sp(a+Rl()+b),long.Parse);} public long[] La3(int a){return Array.ConvertAll(Sp(Rl()+" "+a.ToString()),long.Parse);} public double[] Da2{get{return Array.ConvertAll(Sp("0 "+Rl()+" 0"),double.Parse);}} public double[] Da3(string a,string b){return Array.ConvertAll(Sp(a+Rl()+b),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(Sp(Rl()));}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,Sp(Rl()));}return a;} [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T,T) Tp2<T>(){var s=Sp(Rl());return (Ct<T>(s[0]),Ct<T>(s[1]));} [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T,T,T) Tp3<T>(){var s=Sp(Rl());return (Ct<T>(s[0]),Ct<T>(s[1]),Ct<T>(s[2]));} [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T,T,T,T) Tp4<T>(){var s=Sp(Rl());return (Ct<T>(s[0]),Ct<T>(s[1]),Ct<T>(s[2]),Ct<T>(s[3]));} [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T,T,T,T,T) Tp5<T>(){var s=Sp(Rl());return (Ct<T>(s[0]),Ct<T>(s[1]),Ct<T>(s[2]),Ct<T>(s[3]),Ct<T>(s[4]));} [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T,T,T,T,T,T) Tp6<T>(){var s=Sp(Rl());return (Ct<T>(s[0]),Ct<T>(s[1]),Ct<T>(s[2]),Ct<T>(s[3]),Ct<T>(s[4]),Ct<T>(s[5]));} [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T1,T2) Tp2<T1,T2>(){var s=Sp(Rl());return (Ct<T1>(s[0]),Ct<T2>(s[1]));} [MethodImpl(MethodImplOptions.AggressiveInlining)] public (T1,T1,T2) Tp3<T1,T2>(){var s=Sp(Rl());return (Ct<T1>(s[0]),Ct<T1>(s[1]),Ct<T2>(s[2]));} } public class Scr:Sc{ private List<string> li=new List<string>(); private int l=0; private bool bo=false; [MethodImpl(MethodImplOptions.AggressiveInlining)] protected override string Rl(){ if(bo){return li[l++%li.Count];} li.Add(Console.ReadLine()); return li[li.Count-1]; } public void Again(){bo=true;} } public class Sc2:Sc{ private string[] sps=new string[]{" "," ","\t"}; [MethodImpl(MethodImplOptions.AggressiveInlining)] protected override string[] Sp(string st){return st.Split(sps,StringSplitOptions.RemoveEmptyEntries);} public override int I{get{return int.Parse(Sp(Rl())[0]);}} public override long L{get{return long.Parse(Sp(Rl())[0]);}} public override double D{get{return double.Parse(Sp(Rl())[0]);}} public override string S{get{return Sp(Rl())[0];}} } public class Sct:Sc{ private List<string> li=new List<string>(); private int l=0; public void Add(int s){li.Add(s.ToString());} public void Add(long s){li.Add(s.ToString());} public void Add(double s){li.Add(s.ToString());} public void Add(string s){li.Add(s.ToString());} public void Add(object s){li.Add(s.ToString());} public void Add(int[] s){li.Add(string.Join(" ",s));} public void Add(long[] s){li.Add(string.Join(" ",s));} public void Add(double[] s){li.Add(string.Join(" ",s));} public void Add(string[] s){li.Add(string.Join(" ",s));} public void Add(object[] s){li.Add(string.Join(" ",s));} protected override string Rl(){return li[l++];} public void Clear(){li.Clear();l=0;} public void Again(){l=0;} public void Pf(){Console.WriteLine(string.Join("\n",li));} }