結果
問題 | No.1024 Children in a Row |
ユーザー | tails |
提出日時 | 2020-11-16 18:59:36 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 1,418 bytes |
コンパイル時間 | 311 ms |
コンパイル使用メモリ | 34,964 KB |
実行使用メモリ | 20,096 KB |
最終ジャッジ日時 | 2024-07-23 01:41:31 |
合計ジャッジ時間 | 3,947 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 31 ms
15,232 KB |
testcase_11 | AC | 26 ms
14,592 KB |
testcase_12 | AC | 27 ms
14,848 KB |
testcase_13 | AC | 27 ms
15,232 KB |
testcase_14 | AC | 26 ms
14,592 KB |
testcase_15 | AC | 29 ms
15,104 KB |
testcase_16 | AC | 26 ms
14,848 KB |
testcase_17 | AC | 22 ms
15,360 KB |
testcase_18 | AC | 21 ms
15,104 KB |
testcase_19 | AC | 30 ms
17,388 KB |
testcase_20 | AC | 33 ms
17,408 KB |
testcase_21 | AC | 35 ms
17,364 KB |
testcase_22 | AC | 32 ms
17,344 KB |
testcase_23 | AC | 33 ms
17,280 KB |
testcase_24 | AC | 31 ms
17,356 KB |
testcase_25 | AC | 33 ms
17,408 KB |
testcase_26 | AC | 27 ms
17,380 KB |
testcase_27 | AC | 25 ms
17,436 KB |
testcase_28 | AC | 27 ms
20,096 KB |
testcase_29 | AC | 14 ms
19,716 KB |
コンパイルメッセージ
main.c:28:1: warning: data definition has no type or storage class 28 | latest[200001]; | ^~~~~~ main.c:28:1: warning: type defaults to 'int' in declaration of 'latest' [-Wimplicit-int] main.c:29:1: warning: data definition has no type or storage class 29 | final[200001]; | ^~~~~ main.c:29:1: warning: type defaults to 'int' in declaration of 'final' [-Wimplicit-int] main.c:31:1: warning: return type defaults to 'int' [-Wimplicit-int] 31 | f(i,o){ | ^ main.c: In function 'f': main.c:31:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:31:1: warning: type of 'o' defaults to 'int' [-Wimplicit-int] main.c: At top level: main.c:45:1: warning: return type defaults to 'int' [-Wimplicit-int] 45 | main(){ | ^~~~ main.c: In function 'main': main.c:86:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration] 86 | write(1,wbuf,wp-wbuf); | ^~~~~ main.c:87:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration] 87 | _exit(0); | ^~~~~ | _Exit
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char*mmap(); #define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} char wbuf[7*200000]; typedef struct{ int val; int next; int sib; } Node; typedef struct{ int k; int prev; } Move; typedef struct{ int pos; int len; } Group; Node nodes[400001]; Move moves[200000]; Group groups[400001]; latest[200001]; final[200001]; f(i,o){ do{ groups[i].pos=o; if(latest[nodes[i].val]==i){ final[o++]=nodes[i].val; } if(nodes[i].next){ o=f(nodes[i].next,o); } groups[i].len=o-groups[i].pos; }while(i=nodes[i].sib); return o; } main(){ char*rp=mmap(0l,14l+21l*200000+32,1,2,0,0ll); RD(n); RD(m); for(int i=0;i<=n;++i){ latest[i]=i; nodes[i].val=i; nodes[i].sib=i+1; } nodes[n].sib=0; for(int j=0;j<m;++j){ RD(a); RD(b); RD(k); moves[j].k=k; int la=n+1+j; int lb=latest[b]; moves[j].prev=latest[a]; latest[a]=la; nodes[la].val=a; nodes[la].next=0; nodes[la].sib=nodes[lb].next; nodes[lb].next=la; } f(1,1); char*wp=wbuf; for(int j=0;j<m;++j){ int k=moves[j].k; int p1=groups[j+(n+1)].pos; int le=groups[j+(n+1)].len; int p0=groups[moves[j].prev].pos; k+=p0<p1? k>=p0&k<p1+le?k<p0+le?p1-p0:-le:0: k>=p1&k<p0?le+(k<p0-le?0:p1-p0):0; int z=final[k]; long d=10; int n=1; while(++n,d=d<<8|0x30|z%10,z/=10); *(long*)wp=d; wp+=n; } write(1,wbuf,wp-wbuf); _exit(0); }