結果

問題 No.1639 最小通信路
コンテスト
ユーザー 👑 tails
提出日時 2021-08-10 18:54:40
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 872 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 133 ms
コンパイル使用メモリ 28,184 KB
最終ジャッジ日時 2026-02-22 07:47:41
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c:39:1: error: return type defaults to 'int' [-Wimplicit-int]
   39 | main(){
      | ^~~~
main.c: In function 'main':
main.c:41:17: error: too many arguments to function 'mmap'; expected 0, have 6
   41 |         char*rp=mmap(0l,1l<<25,1,2,0,0ll);
      |                 ^~~~ ~~
main.c:4:6: note: declared here
    4 | char*mmap();
      |      ^~~~
main.c:49:20: error: 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: error: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   55 |         write(1,resp,resn);
      |         ^~~~~
main.c:56:9: error: implicit declaration of function '_exit' [-Wimplicit-function-declaration]
   56 |         _exit(0);
      |         ^~~~~
main.c:56:9: warning: incompatible implicit declaration of built-in function '_exit' [-Wbuiltin-declaration-mismatch]

ソースコード

diff #
raw source code

#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);
}
0