結果
問題 | No.330 Eigenvalue Decomposition |
ユーザー |
![]() |
提出日時 | 2019-04-10 21:34:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 205 ms / 5,000 ms |
コード長 | 1,419 bytes |
コンパイル時間 | 952 ms |
コンパイル使用メモリ | 106,416 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-07-08 02:07:24 |
合計ジャッジ時間 | 4,742 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 31 |
ソースコード
#include <iostream>#include <cstdio>#include <fstream>#include <algorithm>#include <string>#include <map>#include <set>#include <queue>#include <stack>#include <vector>#include <limits.h>#include <math.h>#include <functional>#include <bitset>#include <iomanip>#include <cassert>#include <float.h>#include <random>#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))#define debug(x) cerr << #x << ": " << x << '\n'#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second<< '\n'using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair<int,int> Pii;typedef vector<int> vint;typedef vector<ll> vll;const long long INF = INT_MAX;const ll MOD = 1e9+7;int main(){int N,M;cin>>N>>M;vector<vint> G(N);repeat(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;vector<bool> used(N,false);repeat(i,N){if(used[i])continue;ans++;queue<int> Q;Q.push(i);while(!Q.empty()){int v=Q.front();Q.pop();if(used[v])continue;used[v]=true;for(int u:G[v]){Q.push(u);}}}cout << ans << endl;return 0;}