162512025-04-16 17:23:25algoproKét csoportcpp17Wrong answer 3/100402ms27116 KiB
// UUID: 16fb9623-fd66-43bc-be73-80e01c0fa295
#include <bits/stdc++.h>
using namespace std;

int main() {
	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; cin>>x;
		while(x!=0)
		{
			ellensegek[i].push_back(x);
			hany[i]++;
			cin>>x;
		}
	}
	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();
		for(int x:ellensegek[v])
		{
			if(csop[x]!=csop[v]) hany[x]++;
			else hany[x]--;
			if(hany[x]>1) rosszak.push(x);
		}
		csop[v]=!csop[v];
	}
	cout<<count(csop.begin(), csop.end(), 1)<<endl;
	for(int i=1; i<=n; ++i) if(csop[i]) cout<<i<<' ';
}
SubtaskSumTestVerdictTimeMemory
base3/100
1Wrong answer0/01ms512 KiB
2Time limit exceeded0/0393ms22212 KiB
3Accepted3/31ms316 KiB
4Wrong answer0/31ms316 KiB
5Wrong answer0/31ms500 KiB
6Wrong answer0/31ms316 KiB
7Wrong answer0/31ms316 KiB
8Time limit exceeded0/2388ms25132 KiB
9Time limit exceeded0/3386ms21288 KiB
10Time limit exceeded0/3402ms27116 KiB
11Time limit exceeded0/3389ms21724 KiB
12Time limit exceeded0/3379ms21272 KiB
13Time limit exceeded0/3379ms21188 KiB
14Time limit exceeded0/3400ms18488 KiB
15Time limit exceeded0/6386ms21976 KiB
16Time limit exceeded0/7384ms24780 KiB
17Time limit exceeded0/7384ms22604 KiB
18Time limit exceeded0/6400ms24784 KiB
19Time limit exceeded0/6386ms23736 KiB
20Time limit exceeded0/6375ms21432 KiB
21Time limit exceeded0/6377ms23348 KiB
22Time limit exceeded0/7400ms22656 KiB
23Time limit exceeded0/7381ms17716 KiB
24Time limit exceeded0/7391ms19864 KiB