結果

問題 No.330 Eigenvalue Decomposition
ユーザー tjaketjake
提出日時 2015-12-23 03:29:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 254 ms / 5,000 ms
コード長 1,963 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 80,276 KB
実行使用メモリ 10,428 KB
最終ジャッジ日時 2023-10-18 23:27:17
合計ジャッジ時間 3,609 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
9,628 KB
testcase_01 AC 3 ms
6,000 KB
testcase_02 AC 5 ms
6,076 KB
testcase_03 AC 94 ms
9,628 KB
testcase_04 AC 4 ms
6,000 KB
testcase_05 AC 4 ms
6,048 KB
testcase_06 AC 108 ms
9,216 KB
testcase_07 AC 4 ms
6,000 KB
testcase_08 AC 72 ms
8,112 KB
testcase_09 AC 171 ms
8,508 KB
testcase_10 AC 3 ms
6,000 KB
testcase_11 AC 56 ms
6,756 KB
testcase_12 AC 212 ms
9,216 KB
testcase_13 AC 3 ms
6,000 KB
testcase_14 AC 56 ms
6,948 KB
testcase_15 AC 14 ms
6,388 KB
testcase_16 AC 3 ms
6,000 KB
testcase_17 AC 8 ms
6,164 KB
testcase_18 AC 45 ms
7,500 KB
testcase_19 AC 3 ms
6,000 KB
testcase_20 AC 11 ms
6,268 KB
testcase_21 AC 254 ms
10,428 KB
testcase_22 AC 7 ms
6,068 KB
testcase_23 AC 16 ms
6,320 KB
testcase_24 AC 172 ms
8,284 KB
testcase_25 AC 4 ms
6,000 KB
testcase_26 AC 9 ms
6,068 KB
testcase_27 AC 8 ms
6,092 KB
testcase_28 AC 4 ms
6,000 KB
testcase_29 AC 5 ms
6,044 KB
testcase_30 AC 4 ms
6,000 KB
testcase_31 AC 3 ms
6,000 KB
testcase_32 AC 3 ms
6,000 KB
testcase_33 AC 4 ms
6,000 KB
testcase_34 AC 3 ms
6,000 KB
testcase_35 AC 3 ms
6,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 10000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
typedef pair<P, int> PI;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;


#define N 100000

vector<int> g[N];
bool used[N];

int main() {
  int n, m;
  cin >> n >> m;
  if(n > N) exit(1);
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c; --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  int ans = 0;
  rep(i, n) {
    if(!used[i]) {
      queue<int> que;
      used[i] = true;
      que.push(i);
      ++ans;
      while(!que.empty()) {
        int v = que.front(); que.pop();
        rep(j, g[v].size()) {
          int t = g[v][j];
          if(!used[t]) {
            used[t] = true;
            que.push(t);
          }
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}
0