162592025-04-16 17:34:55algoproKét csoportcpp17Elfogadva 100/100194ms20276 KiB
// UUID: 84d56a4d-38c3-4d09-b1c0-2e3f8a121589
#include <bits/stdc++.h>
#include <ios>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin>>n;
	vector<vector<int>> ellensegek(n+1);
	vector<int> hany(n+1);
	vector<bool> csop(n+1);
	for(int i=1; i<=n; ++i)
	{
		int x;
		while((cin >> x) && x)
		{
			ellensegek[i].push_back(x);
			hany[i]++;
		}
	}
	queue<int> rosszak;
	for(int i=1; i<=n; ++i) if(hany[i]>1) rosszak.push(i);
	while(!rosszak.empty())
	{
		int v=rosszak.front();
		rosszak.pop();
		if(hany[v]<2) continue;
		for(int x:ellensegek[v])
		{
			if(csop[x]!=csop[v]) {
				if(++hany[x]==2) rosszak.push(x);
				hany[v]++;
			}
			else hany[x]--, hany[v]--;
		}
		csop[v]=!csop[v];
	}
	cout<<count(csop.begin(), csop.end(), 1)<<endl;
	for(int i=1; i<=n; ++i) if(csop[i]) cout<<i<<' ';
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base100/100
1Elfogadva0/01ms316 KiB
2Elfogadva0/052ms6712 KiB
3Elfogadva3/31ms316 KiB
4Elfogadva3/31ms316 KiB
5Elfogadva3/31ms316 KiB
6Elfogadva3/31ms316 KiB
7Elfogadva3/31ms316 KiB
8Elfogadva2/21ms512 KiB
9Elfogadva3/31ms316 KiB
10Elfogadva3/31ms316 KiB
11Elfogadva3/31ms316 KiB
12Elfogadva3/36ms820 KiB
13Elfogadva3/36ms892 KiB
14Elfogadva3/37ms1076 KiB
15Elfogadva6/652ms6624 KiB
16Elfogadva7/756ms6944 KiB
17Elfogadva7/763ms6944 KiB
18Elfogadva6/6108ms13108 KiB
19Elfogadva6/6114ms13576 KiB
20Elfogadva6/6126ms13472 KiB
21Elfogadva6/6163ms19352 KiB
22Elfogadva7/7172ms20088 KiB
23Elfogadva7/7194ms20276 KiB
24Elfogadva7/7188ms20276 KiB