結果

問題 No.330 Eigenvalue Decomposition
コンテスト
ユーザー rickytheta
提出日時 2015-12-23 12:58:12
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
RE  
実行時間 -
コード長 263 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 161 ms
コンパイル使用メモリ 32,568 KB
最終ジャッジ日時 2026-02-23 20:15:46
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 4
other AC * 4 RE * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class
    2 | d[100010],i;
      | ^
main.c: In function ‘main’:
main.c:7:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |   scanf("%d%d",&n,&m);
      |   ^~~~~~~~~~~~~~~~~~~
main.c:10:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     scanf("%d%d%d",&a,&b,&c);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>
d[100010],i;
r(x){
  i=d[x]<0?x:(d[x]=r(d[x]));
}
main(n,m,a,b,c){
  scanf("%d%d",&n,&m);
  for(i=n;i--;)d[i]=-1;
  for(;m--;){
    scanf("%d%d%d",&a,&b,&c);
    a=r(a-1);b=r(b-1);
    if(a-b)d[a]+=d[b],d[b]=a,--n;
  }
  i=!printf("%d\n",n);
}
0