Pagini recente »
Atașamentele paginii Profil mihai_brodschi
|
Diferențe pentru utilizator/bogdan_ între reviziile 9 și 14
|
Istoria paginii utilizator/coco06
|
Monitorul de evaluare
|
Cod sursă (job #565540)
Cod sursă (job
#565540)
#include <fstream>
#define NMAX 50050
using namespace std;
ifstream f("beculete.in");
ofstream g("beculete.out");
int n, k, col, line, on_off;
int a[NMAX / 32];
int Get(int pos)
{
int val = (a[pos >> 5] >> (pos & 31)) & 1;
return val;
}
void Set(int pos, int val)
{
int ant = ~(1 << (pos & 31));
a[pos >> 5] = (a[pos >> 5] & ant) ^ (val << (pos & 31));
}
void WorkOnIt(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()
{
f >> n >> k;
Set(1, 1);
for(int i = 2; i <= n; i++)
{
int last = Get(i - 1);
WorkOnIt(i);
Set(i, last);
/*for(int j = 1; j <= i; j++)
g << Get(j) << " ";
g << "\n";*/
while(line <= i && k >= 0)
{
if(line == i)
Set(col, on_off);
f >> line >> col >> on_off;
k--;
}
}
for(int i = 1; i <= n; i++)
g << Get(i) << " ";
return 0;
}