結果

問題 No.556 仁義なきサルたち
コンテスト
ユーザー kotatsugame
提出日時 2017-08-11 23:17:59
言語 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  
(最初)
実行時間 -
コード長 316 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 144 ms
コンパイル使用メモリ 25,140 KB
最終ジャッジ日時 2026-02-22 00:09:10
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c:1:3: warning: multi-character character constant [-Wmultichar]
    1 | p['~~'];c['~~'];i;a,b;
      |   ^~~~
main.c:1:1: warning: data definition has no type or storage class
    1 | p['~~'];c['~~'];i;a,b;
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'p' [-Wimplicit-int]
main.c:1:11: warning: multi-character character constant [-Wmultichar]
    1 | p['~~'];c['~~'];i;a,b;
      |           ^~~~
main.c:1:9: warning: data definition has no type or storage class
    1 | p['~~'];c['~~'];i;a,b;
      |         ^
main.c:1:9: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int]
main.c:1:17: warning: data definition has no type or storage class
    1 | p['~~'];c['~~'];i;a,b;
      |                 ^
main.c:1:17: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
main.c:1:19: warning: data definition has no type or storage class
    1 | p['~~'];c['~~'];i;a,b;
      |                   ^
main.c:1:19: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
main.c:1:21: error: type defaults to 'int' in declaration of 'b' [-Wimplicit-int]
    1 | p['~~'];c['~~'];i;a,b;
      |                     ^
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int]
    2 | f(a){return p[a]-a?p[a]=f(p[a]):a;}
      | ^
main.c: In function 'f':
main.c:2:1: warning: old-style function definition [-Wold-style-definition]
main.c:2:1: error: type of 'a' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int]
    3 | main(n){
      | ^~~~
main.c: In function 'main':
main.c:3:1: warning: old-style function definition [-Wold-style-definition]
main.c:3:1: error: type of 'n' defaults to 'int' [-Wimplicit-int]
main.c:4:13: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    4 |         for(scanf("%d%*d",&n);i++<n;c[i]=1)p[i]=i;
      |             ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration 

ソースコード

diff #
raw source code

p['~~'];c['~~'];i;a,b;
f(a){return p[a]-a?p[a]=f(p[a]):a;}
main(n){
	for(scanf("%d%*d",&n);i++<n;c[i]=1)p[i]=i;
	for(;~scanf("%d%d",&a,&b);)
	{
		a=f(a),b=f(b);
		a-b&&(c[a]>c[b]?p[b]=a,c[a]+=c[b]:c[a]<c[b]?p[a]=b,c[b]+=c[a]:p[a]<p[b]?p[b]=a,c[a]+=c[b]:(p[a]=b,c[b]+=c[a]));
	}
	for(i=0;i++<n;)printf("%d\n",f(i));
}
0