Cod sursa(job #2452808)

Utilizator Bogdan.1108Mandresi Bogdan Bogdan.1108 Data 1 septembrie 2019 13:20:28
Problema Party Scor 60
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.39 kb
#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;
}
bool ok = 1;
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++) p[i] = 1;
    while (ok == 1)
    {
        ok = 0;
    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;
                ok = 1;
                break;
            }
        }
        else if (z == 1)
        {
            if (p[x] == 0 && p[y] != 0)
            {
                p[y] = 0;
                ok = 1;
                break;
            }
        }
        else if (z == 2)
        {
            if (p[y] == 0 && p[x] != 0)
            {
                p[x] = 0;
                ok = 1;
                break;
            }
        }
        else if (z == 3)
        {
            if (p[x] == 1 && p[y] == 1)
            {
                p[y] = 0;
                ok = 1;
                break;
            }
        }
    }
    }
    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;
}