結果

問題 No.330 Eigenvalue Decomposition
ユーザー tailstails
提出日時 2015-12-23 01:10:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 307 ms / 5,000 ms
コード長 501 bytes
コンパイル時間 1,359 ms
コンパイル使用メモリ 161,504 KB
実行使用メモリ 19,844 KB
最終ジャッジ日時 2023-10-18 23:23:36
合計ジャッジ時間 4,390 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
15,460 KB
testcase_01 AC 3 ms
6,000 KB
testcase_02 AC 6 ms
6,184 KB
testcase_03 AC 107 ms
15,460 KB
testcase_04 AC 4 ms
6,000 KB
testcase_05 AC 5 ms
6,108 KB
testcase_06 AC 113 ms
12,340 KB
testcase_07 AC 4 ms
6,000 KB
testcase_08 AC 76 ms
10,156 KB
testcase_09 AC 222 ms
18,524 KB
testcase_10 AC 3 ms
6,000 KB
testcase_11 AC 67 ms
9,892 KB
testcase_12 AC 220 ms
18,588 KB
testcase_13 AC 3 ms
6,000 KB
testcase_14 AC 60 ms
9,392 KB
testcase_15 AC 12 ms
6,404 KB
testcase_16 AC 4 ms
6,000 KB
testcase_17 AC 8 ms
6,256 KB
testcase_18 AC 45 ms
7,964 KB
testcase_19 AC 4 ms
6,000 KB
testcase_20 AC 11 ms
6,436 KB
testcase_21 AC 307 ms
19,844 KB
testcase_22 AC 7 ms
6,252 KB
testcase_23 AC 17 ms
6,844 KB
testcase_24 AC 217 ms
18,476 KB
testcase_25 AC 4 ms
6,000 KB
testcase_26 AC 10 ms
6,440 KB
testcase_27 AC 6 ms
6,088 KB
testcase_28 AC 3 ms
5,996 KB
testcase_29 AC 5 ms
6,040 KB
testcase_30 AC 3 ms
5,996 KB
testcase_31 AC 3 ms
5,996 KB
testcase_32 AC 3 ms
5,996 KB
testcase_33 AC 4 ms
5,996 KB
testcase_34 AC 3 ms
6,000 KB
testcase_35 AC 4 ms
5,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define N 100010

list<int> lnk[N];
char u[N];

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;++i){
		int a,b,c;
		cin>>a>>b>>c;
		lnk[a].push_back(b);
		lnk[b].push_back(a);
	}
	int r=0;
	for(int i=1;i<=n;++i){
		if(!u[i]){
			u[i]=1;
			++r;
			list<int> q;
			q.push_back(i);
			while(!q.empty()){
				int j=q.back();
				q.pop_back();
				for(int k:lnk[j]){
					if(!u[k]){
						u[k]=1;
						q.push_back(k);
					}
				}
			}
		}
	}
	cout<<r;
}
0