結果
問題 | No.1675 Strange Minimum Query |
ユーザー | tails |
提出日時 | 2021-09-11 04:05:26 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 1,966 bytes |
コンパイル時間 | 378 ms |
コンパイル使用メモリ | 34,368 KB |
実行使用メモリ | 16,368 KB |
最終ジャッジ日時 | 2024-06-22 01:27:13 |
合計ジャッジ時間 | 6,974 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 3 ms
7,900 KB |
testcase_02 | AC | 3 ms
6,940 KB |
testcase_03 | AC | 14 ms
11,492 KB |
testcase_04 | AC | 12 ms
12,388 KB |
testcase_05 | AC | 4 ms
6,944 KB |
testcase_06 | AC | 17 ms
13,548 KB |
testcase_07 | AC | 15 ms
14,176 KB |
testcase_08 | AC | 3 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 11 ms
10,980 KB |
testcase_11 | AC | 5 ms
8,724 KB |
testcase_12 | AC | 12 ms
11,368 KB |
testcase_13 | AC | 18 ms
15,984 KB |
testcase_14 | AC | 19 ms
16,368 KB |
testcase_15 | AC | 20 ms
15,732 KB |
testcase_16 | AC | 3 ms
6,940 KB |
testcase_17 | AC | 6 ms
7,396 KB |
testcase_18 | AC | 7 ms
9,292 KB |
testcase_19 | AC | 9 ms
10,280 KB |
testcase_20 | AC | 15 ms
11,748 KB |
testcase_21 | AC | 14 ms
11,368 KB |
testcase_22 | AC | 18 ms
13,896 KB |
testcase_23 | AC | 14 ms
12,408 KB |
testcase_24 | AC | 13 ms
12,560 KB |
testcase_25 | AC | 10 ms
10,208 KB |
testcase_26 | AC | 7 ms
9,180 KB |
testcase_27 | AC | 13 ms
11,104 KB |
testcase_28 | AC | 9 ms
10,496 KB |
testcase_29 | AC | 8 ms
10,044 KB |
testcase_30 | AC | 7 ms
10,132 KB |
testcase_31 | AC | 15 ms
11,872 KB |
testcase_32 | AC | 21 ms
15,728 KB |
testcase_33 | AC | 20 ms
15,600 KB |
testcase_34 | AC | 21 ms
15,596 KB |
testcase_35 | AC | 23 ms
16,112 KB |
testcase_36 | AC | 23 ms
16,112 KB |
コンパイルメッセージ
main.c:67:1: warning: return type defaults to 'int' [-Wimplicit-int] 67 | main(){ | ^~~~ main.c: In function 'main': main.c:108:25: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration] 108 | write(1,"-1\n",3); | ^~~~~ main.c:109:25: warning: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 109 | 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:109:25: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 109 | exit(0); | ^~~~ main.c:109:25: note: include '<stdlib.h>' or provide a declaration of 'exit' main.c:129:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration] 129 | _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[65536]; for(int i=0;i<65536;++i){ c[i]=0; } for(int i=0;i<n;++i){ ++c[(unsigned short)a[i].r]; } int t=0; for(int i=65536;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 short)rb]++; rb=rb<<48|rb>>16; *(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); } 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); }