Cod sursă (job #525418)

Utilizator avatar stefan.popescu Popescu Stefan stefan.popescu IP ascuns
Problemă Beculețe (clasele 9-10) Compilator cpp | 0,67 kb
Rundă Arhiva de probleme Status evaluat
Dată 8 feb. 2020 11:47:07 Scor 0
#include <iostream>
#include <fstream>
#include <bitset>
#include <vector>
using namespace std;
ifstream in ("beculete.in");
ofstream out("beculete.out");
int n, d;
struct tl
{
    int x, y;
    bool val;
};
vector <tl> v;
tl temp;
int poz=0;
bitset <50002> b;
//bitset <50002> a;
int main()
{
    b[1]=1;

    in>>n>>d;
    for(int i=1; i<=d; i++)
    {
        in>>temp.x>>temp.y>>temp.val;
        v.push_back(temp);
    }
    for(int i=2; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
            b[j]=b[j-1]^b[j];
        while(v[poz].x==i)
            b[v[poz].y]=v[poz].val, poz++;
    }
    for(int i=1; i<=n; i++)
        out<<b[i]<<" ";
}