結果
問題 | No.1390 Get together |
ユーザー |
![]() |
提出日時 | 2021-02-12 22:08:02 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 799 bytes |
コンパイル時間 | 1,477 ms |
コンパイル使用メモリ | 30,208 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2024-07-19 21:57:20 |
合計ジャッジ時間 | 1,916 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
main.c:38:1: warning: data definition has no type or storage class 38 | d[200001]; | ^ main.c:38:1: warning: type defaults to 'int' in declaration of 'd' [-Wimplicit-int] main.c:40:1: warning: return type defaults to 'int' [-Wimplicit-int] 40 | main(){ | ^~~~ main.c: In function 'main': main.c:55:9: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 55 | printf("%d",z); | ^~~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf' +++ |+#include <stdio.h> 1 | #pragma GCC optimize("Ofast") main.c:55:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 55 | printf("%d",z); | ^~~~~~ main.c:55:9: note: include '<stdio.h>' or provide a declaration of 'printf'
ソースコード
#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;} #define UFSIZE 200001 int ufbuf[UFSIZE]; void uf_init(){ for(int i=0;i<UFSIZE;++i){ ufbuf[i]=-1; } } int uf_root(int a){ int b; int t=a; while(b=ufbuf[t],b>=0) t=b; while(b=ufbuf[a],b>=0) ufbuf[a]=t,a=b; return t; } int uf_unite(int a,int b){ a=uf_root(a); b=uf_root(b); int r=0; if(a!=b){ if(ufbuf[a]<ufbuf[b]){ ufbuf[a]+=ufbuf[b]; ufbuf[b]=a; }else{ ufbuf[b]+=ufbuf[a]; ufbuf[a]=b; } r=1; } return r; } d[200001]; main(){ char*rp=mmap(0l,1l<<28,1,2,0,0ll); RD(n); RD(m); int z=0; uf_init(); for(int i=0;i<n;++i){ RD(b); RD(c); if(d[c]==0){ d[c]=b; }else{ z+=uf_unite(d[c],b); } } printf("%d",z); }