Pentru această operație este nevoie să te autentifici.
Cod sursă (job #578832)
Utilizator |
|
IP | ascuns |
---|---|---|---|
Problemă | Beculețe (clasele 9-10) | Compilator | cpp-32 | 1.07 kb |
Rundă | lasm_20_01_2021_cl11 | Status | evaluat |
Dată | 20 ian. 2021 18:17:31 | Scor | 10 |
#include <bits/stdc++.h>
using namespace std;
int n, k, col, rind, on_off;
int a[50005];
int Primeste(int pos)
{
int val = (a[pos >> 5] >> (pos & 31)) & 1;
return val;
}
void Pregateste(int pos, int val)
{
unsigned ant = ~(1 << (pos & 31));
a[pos >> 5] = (a[pos >> 5] & ant) ^ (val << (pos & 31));
}
void Solve(int i)
{
for(int bit = i / 32; bit >= 1; bit--)
{
a[bit] = a[bit] ^ (a[bit] << 1);
a[bit] = a[bit] ^ (a[bit - 1] >> 31);
}
a[0] = a[0] ^ (a[0] << 1);
}
int main()
{
ifstream cin("beculete.in");
ofstream cout("beculete.out");
cin >> n >> k;
Pregateste(1, 1);
for(int i = 2; i <= n; i++)
{
int last = Primeste(i - 1);
Solve(i);
Pregateste(i, last);
while(rind <= i && k >= 0)
{
if(rind == i)
Pregateste(col, on_off);
cin >> rind >> col >> on_off;
k--;
}
}
for(int i = 1; i <= n; i++)
cout << Primeste(i) << " ";
return 0;
}