結果

問題 No.768 Tapris and Noel play the game on Treeone
ユーザー chocorusk
提出日時 2018-12-16 03:39:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 884 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 98,584 KB
実行使用メモリ 14,628 KB
最終ジャッジ日時 2024-09-25 06:24:19
合計ジャッジ時間 4,590 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 TLE * 1 -- * 16
権限があれば一括ダウンロードができます

ソースコード

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