Pagini recente » Cod sursa (job #2531426) | Cod sursa (job #2726362) | Cod sursa (job #1617173) | Cod sursa (job #62318) | Cod sursa (job #2452807)
#include <fstream>
using namespace std;
ifstream cin("party.in");
ofstream cout("party.out");
int n, m, x, y, z;
int p[128];
int citire(int x, int y, int z)
{
cin >> x >> y >> z;
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++) p[i] = 1;
for (int i = 1; i <= m; i++)
{
cin >> x >> y >> z;
if (z == 0)
{
if (p[x] == 0 && p[y] == 0)
{
p[x] = 1;
p[y] = 1;
}
}
else if (z == 1)
{
if (p[x] == 0 && p[y] != 0)
{
p[y] = 0;
}
}
else if (z == 2)
{
if (p[y] == 0 && p[x] != 0)
{
p[x] = 0;
}
}
else if (z == 3)
{
if (p[x] == 1 && p[y] == 1)
{
p[y] = 0;
}
}
}
int k = 0;
for (int i = 1; i <= n; i++)
if (p[i]) k++;
cout << k << endl;
for (int i = 1; i <= n; i++)
if (p[i]) cout << i << endl;
return 0;
}