結果
問題 | No.1675 Strange Minimum Query |
ユーザー | tails |
提出日時 | 2021-09-11 04:08:48 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 2,053 bytes |
コンパイル時間 | 273 ms |
コンパイル使用メモリ | 34,424 KB |
実行使用メモリ | 15,860 KB |
最終ジャッジ日時 | 2024-06-22 01:32:56 |
合計ジャッジ時間 | 4,687 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 14 ms
12,008 KB |
testcase_04 | AC | 10 ms
10,728 KB |
testcase_05 | AC | 3 ms
6,944 KB |
testcase_06 | AC | 14 ms
12,644 KB |
testcase_07 | AC | 14 ms
13,928 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 1 ms
6,944 KB |
testcase_10 | AC | 10 ms
10,856 KB |
testcase_11 | AC | 3 ms
6,940 KB |
testcase_12 | AC | 10 ms
11,372 KB |
testcase_13 | AC | 18 ms
15,728 KB |
testcase_14 | AC | 16 ms
13,620 KB |
testcase_15 | AC | 17 ms
15,472 KB |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | AC | 5 ms
8,740 KB |
testcase_18 | AC | 5 ms
8,932 KB |
testcase_19 | AC | 8 ms
9,968 KB |
testcase_20 | AC | 14 ms
11,624 KB |
testcase_21 | AC | 13 ms
13,292 KB |
testcase_22 | AC | 16 ms
12,004 KB |
testcase_23 | AC | 12 ms
11,752 KB |
testcase_24 | AC | 12 ms
11,124 KB |
testcase_25 | AC | 9 ms
10,212 KB |
testcase_26 | AC | 6 ms
9,068 KB |
testcase_27 | AC | 12 ms
11,960 KB |
testcase_28 | AC | 7 ms
9,780 KB |
testcase_29 | AC | 6 ms
9,328 KB |
testcase_30 | AC | 6 ms
9,160 KB |
testcase_31 | AC | 15 ms
11,616 KB |
testcase_32 | AC | 20 ms
13,032 KB |
testcase_33 | AC | 20 ms
15,344 KB |
testcase_34 | AC | 20 ms
15,472 KB |
testcase_35 | AC | 21 ms
15,732 KB |
testcase_36 | AC | 24 ms
15,860 KB |
コンパイルメッセージ
main.c:71:1: warning: return type defaults to 'int' [-Wimplicit-int] 71 | main(){ | ^~~~ main.c: In function 'main': main.c:112:25: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration] 112 | write(1,"-1\n",3); | ^~~~~ main.c:113:25: warning: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 113 | exit(0); | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | #pragma GCC optimize("Ofast") main.c:113:25: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 113 | exit(0); | ^~~~ main.c:113:25: note: include '<stdlib.h>' or provide a declaration of 'exit' main.c:133:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration] 133 | _exit(0); | ^~~~~ | _Exit
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char*mmap(); static char wbuf[1<<25]; #define wbuf_end (wbuf+sizeof wbuf) #define rd(v) long v=0;{long _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} #define rep(v,e) for(long v=0;v<e;++v) #define reps(v,s,e) for(long v=s;v<e;++v) #define rrep(v,e) for(long v=e;v--;) static int base10x4[10000]; static void mkbase10(){ long i=0; reps(a,'0','9'+1){ reps(b,'0','9'+1){ reps(c,'0','9'+1){ reps(d,'0','9'+1){ base10x4[i++]=a|b<<8|c<<16|d<<24; } } } } } typedef struct{ int r,b,l; }S; static void radix_sort_aux(S*a,S*b,int n){ int c[256]; for(int i=0;i<256;++i){ c[i]=0; } for(int i=0;i<n;++i){ ++c[(unsigned char)a[i].r]; } int t=0; for(int i=256;i--;){ int u=c[i]; c[i]=t; t+=u; } for(int i=0;i<n;++i){ S v=a[i]; unsigned long rb=*(unsigned long*)&v; long j=c[(unsigned char)rb]++; rb=rb<<56|rb>>8; *(unsigned long*)&v=rb; b[j]=v; } } static void radix_sort(S*a,int n){ static S b[200000]; radix_sort_aux(a,b,n); radix_sort_aux(b,a,n); radix_sort_aux(a,b,n); radix_sort_aux(b,a,n); radix_sort_aux(a,b,n); radix_sort_aux(b,a,n); radix_sort_aux(a,b,n); radix_sort_aux(b,a,n); } static S a[200000]; static int s[200000],z[200000]; main(){ mkbase10(); char*rp=mmap(0l,1l<<25,1,2,0,0ll); rd(n); rd(q); rep(i,q){ rd(l); a[i].l=l-1; rd(r); a[i].r=-r; rd(b); a[i].b=b; } radix_sort(a,q); long fb=0,fi=0; rep(i,q){ int b=a[i].b; int l=a[i].l; int r=-a[i].r; int f=(fb==b&&fi>=l); while(1){ int t=l; while(t<r&&s[t]){ t=s[t]; } while(l!=t){ int u=s[l]; s[l]=t; l=u; } if(l>=r){ break; } f=1; s[l]=l+1; z[l]=b; if(!(fb==b&&fi>=l)){ fb=b; fi=l; } } if(!f){ write(1,"-1\n",3); exit(0); } } char*wp=wbuf_end; *--wp='\n'; rrep(i,n){ int x=z[i]; if(x){ do{ *(int*)(wp-=4)=base10x4[x%10000]; }while(x/=10000); while(*wp=='0')++wp; }else{ *--wp='1'; } *--wp=' '; } ++wp; write(1,wp,wbuf_end-wp); _exit(0); }