結果
問題 | No.1675 Strange Minimum Query |
ユーザー | fgwiebfaoish |
提出日時 | 2021-09-15 21:55:20 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 599 ms / 2,000 ms |
コード長 | 4,845 bytes |
コンパイル時間 | 2,796 ms |
コンパイル使用メモリ | 109,184 KB |
実行使用メモリ | 68,736 KB |
最終ジャッジ日時 | 2024-06-28 23:26:50 |
合計ジャッジ時間 | 19,810 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
18,304 KB |
testcase_01 | AC | 26 ms
18,304 KB |
testcase_02 | AC | 27 ms
18,560 KB |
testcase_03 | AC | 373 ms
32,640 KB |
testcase_04 | AC | 351 ms
36,480 KB |
testcase_05 | AC | 78 ms
31,872 KB |
testcase_06 | AC | 433 ms
34,560 KB |
testcase_07 | AC | 474 ms
38,784 KB |
testcase_08 | AC | 28 ms
18,432 KB |
testcase_09 | AC | 30 ms
18,672 KB |
testcase_10 | AC | 246 ms
50,944 KB |
testcase_11 | AC | 104 ms
41,344 KB |
testcase_12 | AC | 268 ms
54,656 KB |
testcase_13 | AC | 462 ms
68,736 KB |
testcase_14 | AC | 504 ms
64,768 KB |
testcase_15 | AC | 469 ms
67,072 KB |
testcase_16 | AC | 28 ms
18,432 KB |
testcase_17 | AC | 111 ms
31,232 KB |
testcase_18 | AC | 147 ms
32,896 KB |
testcase_19 | AC | 211 ms
51,200 KB |
testcase_20 | AC | 393 ms
51,072 KB |
testcase_21 | AC | 361 ms
55,808 KB |
testcase_22 | AC | 453 ms
59,392 KB |
testcase_23 | AC | 344 ms
38,784 KB |
testcase_24 | AC | 325 ms
45,696 KB |
testcase_25 | AC | 242 ms
35,200 KB |
testcase_26 | AC | 141 ms
36,224 KB |
testcase_27 | AC | 328 ms
56,576 KB |
testcase_28 | AC | 190 ms
45,696 KB |
testcase_29 | AC | 156 ms
49,024 KB |
testcase_30 | AC | 141 ms
37,248 KB |
testcase_31 | AC | 450 ms
43,392 KB |
testcase_32 | AC | 599 ms
63,872 KB |
testcase_33 | AC | 586 ms
63,744 KB |
testcase_34 | AC | 594 ms
63,872 KB |
testcase_35 | AC | 577 ms
65,280 KB |
testcase_36 | AC | 584 ms
65,280 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.Text.RegularExpressions; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using System.Threading; using System.Runtime.CompilerServices; using System.Diagnostics; using nint=System.Int32; static class Program{ const int mod=(int)1e9+7; static void Main(){ Sc sc=new Sc(); var (n,m)=sc.Tp2<int>(); St st=new St(n,1,true); var h=new int[m][]; for(int i = 0;i<m;i++) { h[i]=sc.Ia; h[i][0]--; h[i][1]--; st.Add(h[i][0],h[i][1],h[i][2]); } var ans=new int[n]; for(int i = 0;i<n;i++) {ans[i]=(int)st.Get(i);} Spt spt=new Spt(ans,false); for(int i = 0;i<m;i++) { if(spt.Get(h[i][0],h[i][1])!=h[i][2]){ Console.WriteLine(-1); return; } } Console.WriteLine("{0}",string.Join(" ",ans)); } } public class Spt{ private readonly nint[][] d; private readonly int[] l; private Func<nint,nint,nint> Fu; public Spt(nint[] a,bool bo){ int n=a.Length,m=(int)Log(n,2)+1; d=new nint[m][]; d[0]=new nint[n]; l=new int[n+1]; if(bo){Fu=(y,x)=>Max(y,x);} else{Fu=(y,x)=>Min(y,x);} for(int i=0;i<n;i++){ d[0][i]=a[i]; l[i+1]=l[i>>1]+1; } for(int i=1,k=1;i<m;i++,k<<=1){ int p=n+1-(k<<1); d[i]=new nint[p]; for(int j=0;j<p;j++){d[i][j]=Fu(d[i-1][j],d[i-1][j+k]);} } } public nint Get(int a,int b){ if(a>b){(a,b)=(b,a);} int p=l[b-a]; return Fu(d[p][a],d[p][b+1-(1<<p)]); } } public class St{ private long[] dat; private int m=1,cnt=0; private long d; private Func<long,long,long> Fm; public St(int n,long d,bool bo){ if(bo){Fm=Fmax;} else{Fm=Fmin;} this.d=d; while(m<n){m<<=1;} cnt=m+n-1; dat=new long[cnt]; for(int i = 0;i<cnt;i++) {dat[i]=d;} } private long Fmax(long a,long b){return Max(a,b);} private long Fmin(long a,long b){return Min(a,b);} public long Get(int q){ long p=d; q+=m-1; while(q>=0){p=Fm(dat[q],p);q=(q-1)>>1;} return p; } public void Add(int a,int b,long d){Hn(a,b,0,0,m-1,d);} private void Hn(int a,int b,int k,int l,int r,long d){ if(a<=l&&r<=b){dat[k]=Fm(dat[k],d);} else if(l<=b&&a<=r){ Hn(a,b,k*2+1,l,(l+r)>>1,d); Hn(a,b,k*2+2,(l+r+1)>>1,r,d); } } } 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(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);} public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);} public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}} public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);} public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);} public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}} public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).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;} public (T,T) Tp2<T>(){var s=Console.ReadLine().Split();return (Ct<T>(s[0]),Ct<T>(s[1]));} public (T,T,T) Tp3<T>(){var s=Console.ReadLine().Split();return (Ct<T>(s[0]),Ct<T>(s[1]),Ct<T>(s[2]));} public (T,T,T,T) Tp4<T>(){var s=Console.ReadLine().Split();return (Ct<T>(s[0]),Ct<T>(s[1]),Ct<T>(s[2]),Ct<T>(s[3]));} public (T1,T2) Tp2<T1,T2>(){var s=Console.ReadLine().Split();return (Ct<T1>(s[0]),Ct<T2>(s[1]));} public (T1,T1,T2) Tp3<T1,T2>(){var s=Console.ReadLine().Split();return (Ct<T1>(s[0]),Ct<T1>(s[1]),Ct<T2>(s[2]));} private T Ct<T>(string s){return (T)Convert.ChangeType(s,typeof(T));} }