結果

問題 No.768 Tapris and Noel play the game on Treeone
ユーザー chocoruskchocorusk
提出日時 2018-12-16 03:39:02
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 884 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 99,384 KB
実行使用メモリ 5,824 KB
最終ジャッジ日時 2023-10-25 22:04:29
合計ジャッジ時間 5,019 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,788 KB
testcase_01 AC 3 ms
5,788 KB
testcase_02 AC 3 ms
5,788 KB
testcase_03 AC 8 ms
5,816 KB
testcase_04 AC 13 ms
5,824 KB
testcase_05 AC 10 ms
5,816 KB
testcase_06 AC 6 ms
5,808 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
20evil_special_uni1.txt -- -
20evil_special_uni2.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
vector<int> g[100000];
bool w[100000];
bool used[100000];
void dfs(int x){
	used[x]=1;
	w[x]=1;
	for(auto y:g[x]){
		if(used[y]) continue;
		dfs(y);
		if(w[y]) w[x]=0;
	}
}
int main()
{
	int n; cin>>n;
	for(int i=0; i<n-1; i++){
		int a, b;
		cin>>a>>b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> ans;
	for(int i=0; i<n; i++){
		fill(used, used+n, 0);
		dfs(i);
		if(w[i]) ans.push_back(i);
	}
	cout<<ans.size()<<endl;
	for(auto x:ans) cout<<x+1<<endl;
	return 0;
}
0