99902024-03-23 17:40:17111Két csoportcpp17Wrong answer 41/100270ms43000 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen("be2.txt","r",stdin);
#endif
	int N;
	cin>>N;
	vector<vector<int>>g(N+1);
	for(int i=1;i<=N;i++){
		for(int j;cin>>j,j;){
			g[i].push_back(j);
		}
	}
	vector<int>v(N+1);
	auto dfs=[&](auto self,int i)->void{
		array<vector<int>,3>a;
		for(int j:g[i]){
			a[v[j]].push_back(j);
		}
		v[i]=a[1].size()<=a[2].size()?1:2;
		for(int j:a[0]){
			self(self,j);
		}
	};
	for(int i=1;i<=N;i++){
		if(v[i]){
			continue;
		}
		dfs(dfs,i);
	}
	vector<int>ans;
	for(int i=1;i<=N;i++){
		if(v[i]==1){
			ans.push_back(i);
		}
	}
	cout<<ans.size()<<'\n';
	for(int i:ans){
		cout<<i<<' ';
	}
	cout<<'\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base41/100
1Accepted0/03ms400 KiB
2Accepted0/064ms8036 KiB
3Accepted3/33ms392 KiB
4Accepted3/33ms524 KiB
5Accepted3/33ms508 KiB
6Accepted3/33ms376 KiB
7Accepted3/33ms356 KiB
8Accepted2/22ms376 KiB
9Accepted3/33ms504 KiB
10Wrong answer0/33ms504 KiB
11Wrong answer0/33ms488 KiB
12Accepted3/38ms1252 KiB
13Wrong answer0/39ms1180 KiB
14Wrong answer0/310ms2168 KiB
15Accepted6/664ms7960 KiB
16Wrong answer0/774ms8448 KiB
17Wrong answer0/792ms14648 KiB
18Accepted6/6126ms15512 KiB
19Wrong answer0/6148ms16916 KiB
20Wrong answer0/6184ms28432 KiB
21Accepted6/6186ms23208 KiB
22Time limit exceeded0/7221ms24148 KiB
23Time limit exceeded0/7263ms36452 KiB
24Time limit exceeded0/7270ms43000 KiB