結果
問題 | No.1451 集団登校 |
ユーザー | tails |
提出日時 | 2021-04-05 17:01:44 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 1,456 bytes |
コンパイル時間 | 446 ms |
コンパイル使用メモリ | 33,408 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-10 02:04:00 |
合計ジャッジ時間 | 2,891 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 3 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 3 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 3 ms
6,940 KB |
testcase_13 | AC | 5 ms
6,944 KB |
testcase_14 | AC | 6 ms
6,940 KB |
testcase_15 | AC | 3 ms
6,940 KB |
testcase_16 | AC | 5 ms
6,944 KB |
testcase_17 | AC | 5 ms
6,940 KB |
testcase_18 | AC | 3 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 8 ms
6,944 KB |
testcase_21 | AC | 3 ms
6,940 KB |
testcase_22 | AC | 3 ms
6,944 KB |
testcase_23 | AC | 2 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 4 ms
6,940 KB |
testcase_26 | AC | 5 ms
6,944 KB |
testcase_27 | AC | 6 ms
6,944 KB |
testcase_28 | AC | 3 ms
6,940 KB |
testcase_29 | AC | 4 ms
6,944 KB |
コンパイルメッセージ
main.c:68:1: warning: return type defaults to 'int' [-Wimplicit-int] 68 | main(){ | ^~~~ main.c: In function 'main': main.c:70:9: warning: implicit declaration of function 'sprintf' [-Wimplicit-function-declaration] 70 | sprintf(w[0],"%11d\n",0); | ^~~~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'sprintf' +++ |+#include <stdio.h> 1 | #pragma GCC optimize("Ofast") main.c:70:9: warning: incompatible implicit declaration of built-in function 'sprintf' [-Wbuiltin-declaration-mismatch] 70 | sprintf(w[0],"%11d\n",0); | ^~~~~~~ main.c:70:9: note: include '<stdio.h>' or provide a declaration of 'sprintf' main.c:70:18: warning: passing argument 1 of 'sprintf' from incompatible pointer type [-Wincompatible-pointer-types] 70 | sprintf(w[0],"%11d\n",0); | ~^~~ | | | int * main.c:70:18: note: expected 'char *' but argument is of type 'int *' main.c:74:34: warning: passing argument 1 of 'sprintf' from incompatible pointer type [-Wincompatible-pointer-types] 74 | sprintf(w[i+1],"%11d\n",z); | ~^~~~~ | | | int * main.c:74:34: note: expected 'char *' but argument is of type 'int *' main.c:103:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration] 103 | write(1,wbuf,(wp-wbuf)*sizeof*wbuf); | ^~~~~ main.c:104:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration] 104 | _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;} int wbuf[1<<28]; #define UFSIZE 100001 typedef struct{ int p; int v; } UFDPNode; #define u ufdpnodes UFDPNode u[UFSIZE]; void ufdp_init(){ for(int i=0;i<UFSIZE;++i){ u[i].p=-1; u[i].v=0; } } int ufdp_root(int a){ int b=u[a].p; if(b<0){ return a; }else{ int r=ufdp_root(b); if(r!=b){ if(u[a].v>=0){ u[a].v=u[b].v<0?u[b].v:u[b].v+u[a].v; u[a].p=r; } } return r; } } void ufdp_unite(int a,int b){ a=ufdp_root(a); b=ufdp_root(b); if(a!=b){ if(u[a].p<u[b].p){ u[a].p+=u[b].p; u[b].p=a; u[b].v=-1; }else if(u[a].p>u[b].p){ u[b].p+=u[a].p; u[a].p=b; u[a].v=-1; }else{ if(u[a].v<u[b].v){ u[a].p+=u[b].p; u[b].p=a; u[b].v-=u[a].v; u[a].v+=1; }else{ u[b].p+=u[a].p; u[a].p=b; u[a].v-=u[b].v; u[b].v+=1; } } } } main(){ int w[21][4]; sprintf(w[0],"%11d\n",0); { int z=1; for(int i=0;i<20;++i){ sprintf(w[i+1],"%11d\n",z); z=(z>>1)+(z&1?500000004:0); } } char*rp=mmap(0l,1l<<28,1,2,0,0ll); ufdp_init(); rd(n); rd(m); while(m--){ rd(a); rd(b); ufdp_unite(a,b); } int*wp=wbuf; for(int i=1;i<=n;++i){ int r=ufdp_root(i); int v=u[i].v; if(v>=0&&r!=i){ v+=u[r].v; } *wp++=w[v+1][0]; *wp++=w[v+1][1]; *wp++=w[v+1][2]; } write(1,wbuf,(wp-wbuf)*sizeof*wbuf); _exit(0); }