結果
問題 | No.1024 Children in a Row |
ユーザー | tails |
提出日時 | 2020-11-16 18:37:52 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 1,425 bytes |
コンパイル時間 | 627 ms |
コンパイル使用メモリ | 34,976 KB |
実行使用メモリ | 20,064 KB |
最終ジャッジ日時 | 2024-07-23 01:41:16 |
合計ジャッジ時間 | 5,850 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
9,576 KB |
testcase_02 | AC | 3 ms
9,580 KB |
testcase_03 | AC | 2 ms
9,576 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 3 ms
7,668 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
9,704 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
9,576 KB |
testcase_10 | AC | 31 ms
16,532 KB |
testcase_11 | AC | 29 ms
16,404 KB |
testcase_12 | AC | 30 ms
16,464 KB |
testcase_13 | AC | 32 ms
16,616 KB |
testcase_14 | AC | 33 ms
16,504 KB |
testcase_15 | AC | 32 ms
16,484 KB |
testcase_16 | AC | 28 ms
16,468 KB |
testcase_17 | AC | 25 ms
16,872 KB |
testcase_18 | AC | 23 ms
16,508 KB |
testcase_19 | AC | 39 ms
17,360 KB |
testcase_20 | AC | 39 ms
17,304 KB |
testcase_21 | AC | 40 ms
17,292 KB |
testcase_22 | AC | 38 ms
17,360 KB |
testcase_23 | AC | 38 ms
17,224 KB |
testcase_24 | AC | 36 ms
17,380 KB |
testcase_25 | AC | 38 ms
17,312 KB |
testcase_26 | AC | 32 ms
17,308 KB |
testcase_27 | AC | 29 ms
17,540 KB |
testcase_28 | AC | 34 ms
20,064 KB |
testcase_29 | AC | 15 ms
19,888 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:46:1: warning: return type defaults to 'int' [-Wimplicit-int] 46 | main(){ | ^~~~ main.c: In function 'main': main.c:87:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration] 87 | write(1,wbuf,wp-wbuf); | ^~~~~ main.c:88:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration] 88 | _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){ 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; if(nodes[i].sib){ o=f(nodes[i].sib,o); } 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); }