結果
問題 | No.1014 competitive fighting |
ユーザー | fgwiebfaoish |
提出日時 | 2022-01-18 00:00:23 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 827 ms / 2,000 ms |
コード長 | 8,181 bytes |
コンパイル時間 | 5,659 ms |
コンパイル使用メモリ | 120,180 KB |
実行使用メモリ | 118,276 KB |
最終ジャッジ日時 | 2024-11-23 13:02:46 |
合計ジャッジ時間 | 32,758 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
18,944 KB |
testcase_01 | AC | 32 ms
18,944 KB |
testcase_02 | AC | 32 ms
19,072 KB |
testcase_03 | AC | 32 ms
19,072 KB |
testcase_04 | AC | 32 ms
19,200 KB |
testcase_05 | AC | 808 ms
90,896 KB |
testcase_06 | AC | 819 ms
90,388 KB |
testcase_07 | AC | 824 ms
90,552 KB |
testcase_08 | AC | 816 ms
91,936 KB |
testcase_09 | AC | 820 ms
90,424 KB |
testcase_10 | AC | 601 ms
83,544 KB |
testcase_11 | AC | 764 ms
117,444 KB |
testcase_12 | AC | 827 ms
90,704 KB |
testcase_13 | AC | 358 ms
56,312 KB |
testcase_14 | AC | 334 ms
53,488 KB |
testcase_15 | AC | 410 ms
60,024 KB |
testcase_16 | AC | 44 ms
23,168 KB |
testcase_17 | AC | 146 ms
35,712 KB |
testcase_18 | AC | 654 ms
82,396 KB |
testcase_19 | AC | 816 ms
89,852 KB |
testcase_20 | AC | 263 ms
48,112 KB |
testcase_21 | AC | 593 ms
77,676 KB |
testcase_22 | AC | 480 ms
65,772 KB |
testcase_23 | AC | 187 ms
40,192 KB |
testcase_24 | AC | 192 ms
41,332 KB |
testcase_25 | AC | 68 ms
26,624 KB |
testcase_26 | AC | 585 ms
76,528 KB |
testcase_27 | AC | 139 ms
35,072 KB |
testcase_28 | AC | 160 ms
37,248 KB |
testcase_29 | AC | 37 ms
20,992 KB |
testcase_30 | AC | 772 ms
90,212 KB |
testcase_31 | AC | 605 ms
78,432 KB |
testcase_32 | AC | 36 ms
20,480 KB |
testcase_33 | AC | 71 ms
28,928 KB |
testcase_34 | AC | 562 ms
96,344 KB |
testcase_35 | AC | 772 ms
118,276 KB |
testcase_36 | AC | 513 ms
84,976 KB |
testcase_37 | AC | 49 ms
24,960 KB |
testcase_38 | AC | 472 ms
82,544 KB |
testcase_39 | AC | 239 ms
54,508 KB |
testcase_40 | AC | 458 ms
82,184 KB |
testcase_41 | AC | 325 ms
62,312 KB |
testcase_42 | AC | 745 ms
111,328 KB |
testcase_43 | AC | 63 ms
27,136 KB |
testcase_44 | AC | 651 ms
108,040 KB |
testcase_45 | AC | 385 ms
74,056 KB |
testcase_46 | AC | 88 ms
31,104 KB |
testcase_47 | AC | 224 ms
52,072 KB |
testcase_48 | AC | 535 ms
90,048 KB |
testcase_49 | AC | 51 ms
25,344 KB |
testcase_50 | AC | 676 ms
112,760 KB |
testcase_51 | AC | 391 ms
75,448 KB |
testcase_52 | AC | 53 ms
25,856 KB |
testcase_53 | AC | 813 ms
92,168 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 System.Threading; using System.Runtime.CompilerServices; using System.Diagnostics; static class Program{ const int mod=(int)1e9+7; const long inf=long.MaxValue>>1; static List<int>[] li; static void Main(){ Sc sc=new Sc(); var n=sc.I; int m=(n+1)<<1; li=new List<int>[m]; for(int i=1;i<m;i++){li[i]=new List<int>();} var h=new int[n+2][]; h[0]=new int[]{-mod,-mod,-mod}; h[n+1]=new int[]{mod,mod,mod}; for(int i = 1;i<=n;i++) {h[i]=sc.Ia3(i);} var stg=new Stg(1,n,n+1,(v1,v2)=>{ li[v2].Add(v1); }); Array.Sort(h,(u,v)=>u[0]-v[0]); for(int i = 1;i<=n;i++) { int lb = -1, ub = n+1, mid = 0; while(lb+1!=ub) { mid=(ub+lb)/2; if(h[mid][0]>h[i][1]-h[i][2]) { ub=mid; } else { lb=mid; } } if(lb<i&&lb>=1){ stg.Get(1,lb,v=>{li[v].Add(i);}); } else if(lb>=1){ if(1<=i-1){stg.Get(1,i-1,v=>{li[v].Add(i);});} if(i+1<=lb){stg.Get(i+1,lb,v=>{li[v].Add(i);});} } } var scc=new Scc(li); var dp=new long[scc.li.Length]; var ans=new long[n+1]; for(int i=1;i<scc.li.Length;i++){ if(scc.da[i].Length>1){dp[i]=inf;} else if(scc.da[i][0]<=n){dp[i]+=h[scc.da[i][0]][1];} for(int j = 0;j<scc.li[i].Count;j++) {dp[scc.li[i][j]]=Max(dp[scc.li[i][j]],dp[i]);} for(int j = 0;j<scc.da[i].Length;j++) { if(scc.da[i][j]<=n){ans[h[scc.da[i][j]][3]]=dp[i];} } } StringBuilder sb=new StringBuilder(); for(int i = 1;i<=n;i++) {sb.Append((ans[i]>=inf?"BAN":ans[i].ToString())+"\n");} Console.Write(sb); } } public class Scc{ private const int o=1; public List<int>[] li; public int[][] da; public int[] h; public readonly int m; public Scc(List<int>[] lim){ int n=lim.Length,p=1; var b=new bool[n]; var b2=new bool[n]; var b3=new bool[n]; var low=new int[n]; h=new int[n]; var sk=new Stack<int>(); var lid=new List<List<int>>(); for(int i = o;i<n;i++) {if(!b[i]){Fud(i);}} void Fud(int a){ b[a]=true; low[a]=p++; sk.Push(a); for(int i=0;i<lim[a].Count;i++){ if(b2[lim[a][i]]){continue;} if(!b[lim[a][i]]){Fud(lim[a][i]);} if(low[a]>low[lim[a][i]]){ low[a]=low[lim[a][i]]; b3[a]=true; } } if(b3[a]){return;} int v=-1; lid.Add(new List<int>()); while(v!=a){ v=sk.Pop(); lid[lid.Count-1].Add(v); b2[v]=true; h[v]=lid.Count-1; } } m=lid.Count+o; li=new List<int>[m]; da=new int[m][]; for(int i = o;i<m;i++) {li[i]=new List<int>();} for(int i = o;i<n;i++) {h[i]=lid.Count-h[i]-1+o;} for(int i = lid.Count-1;i>=0;i--) { int e=m-i-1; da[e]=lid[i].ToArray(); for(int j = 0;j<da[e].Length;j++) { for(int k = 0;k<lim[da[e][j]].Count;k++) { if(h[lim[da[e][j]][k]]!=e){li[e].Add(h[lim[da[e][j]][k]]);} } } } for(int i = o;i<m;i++) {li[i]=li[i].Distinct().ToList();} m-=o; } } public class Stg{ private int[] h; private int n,lm; public int m; public Stg(int l,int r,int a,Action<int,int> f){ lm=l; n=r-l+1; var cnt=n<<1; h=new int[cnt]; h[0]=a-1; for(int i = 1;i<cnt;i++) {h[i]=i+n>=cnt?l+i-n:(a+i-1);} for(int i = 1;i<cnt-n;i++) { f(h[i],h[i<<1]); f(h[i],h[(i<<1)+1]); } m=h[cnt-n-1]; } public void Get(int l,int r,Action<int> f){ l+=n-lm;r+=n-lm; while(l<=r){ if((l&1)==1){ f(h[l]); l++; } if((r&1)==0){ f(h[r]); r--; } l>>=1;r>>=1; } } } 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 Scs:Sc{ private StreamReader sr; public Scs(string t){sr=new StreamReader(t);} [MethodImpl(MethodImplOptions.AggressiveInlining)] protected override string Rl(){return sr.ReadLine();} } 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 Scs2:Sc2{ private StreamReader sr; public Scs2(string t){sr=new StreamReader(t);} [MethodImpl(MethodImplOptions.AggressiveInlining)] protected override string Rl(){return sr.ReadLine();} } 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;} }