結果
問題 | No.1639 最小通信路 |
ユーザー |
![]() |
提出日時 | 2021-08-10 18:54:40 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 872 bytes |
コンパイル時間 | 531 ms |
コンパイル使用メモリ | 30,080 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 21:04:13 |
合計ジャッジ時間 | 1,546 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 43 |
コンパイルメッセージ
main.c:39:1: warning: return type defaults to 'int' [-Wimplicit-int] 39 | main(){ | ^~~~ main.c: In function 'main': main.c:49:20: warning: implicit declaration of function 'strchr' [-Wimplicit-function-declaration] 49 | rp=strchr(rp,'\n')+1; | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'strchr' +++ |+#include <string.h> 1 | #pragma GCC optimize("Ofast") main.c:49:20: warning: incompatible implicit declaration of built-in function 'strchr' [-Wbuiltin-declaration-mismatch] 49 | rp=strchr(rp,'\n')+1; | ^~~~~~ main.c:49:20: note: include '<string.h>' or provide a declaration of 'strchr' main.c:55:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration] 55 | write(1,resp,resn); | ^~~~~ main.c:56:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration] 56 | _exit(0); | ^~~~~ | _Exit
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char*mmap(); #define rd_skip() while(*rp++>=48) #define rd(v) long v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} #define UFSIZE 101 long ufbuf[UFSIZE]; void uf_init(){ for(long i=0;i<UFSIZE;++i){ ufbuf[i]=-1; } } long uf_root(long a){ long b; long t=a; while(b=ufbuf[t],b>=0) t=b; while(b=ufbuf[a],b>=0) ufbuf[a]=t,a=b; return t; } long uf_unite(long a,long b){ a=uf_root(a); b=uf_root(b); if(a!=b){ if(ufbuf[a]<ufbuf[b]){ ufbuf[a]+=ufbuf[b]; ufbuf[b]=a; }else{ ufbuf[b]+=ufbuf[a]; ufbuf[a]=b; } return 1; }else{ return 0; } } main(){ uf_init(); char*rp=mmap(0l,1l<<25,1,2,0,0ll); rd_skip(); char*resp; long resn; while(*rp){ rd(a); rd(b); char*c=rp; rp=strchr(rp,'\n')+1; if(uf_unite(a,b)){ resp=c; resn=rp-c; } } write(1,resp,resn); _exit(0); }