Pagini recente » Cod sursa (job #1836737) | Cod sursa (job #1924010) | Cod sursa (job #3253958) | Cod sursa (job #1618163) | Cod sursa (job #1776369)
#include <cstdio>
#include <ctype.h>
#define BUF_SIZE (1<<17)
#define DIM (1<<18)
char buf[BUF_SIZE], buf2[BUF_SIZE];
int n, m, pos = BUF_SIZE, pos2, l1, l2, poz, lazy[DIM];
FILE *fin, *fout;
inline char getChar();
inline int getInt();
inline void putch(char);
inline void scrie(int);
void update(int st, int dr, int nod, int t)
{
if(l1 <= st && dr <= l2){
lazy[nod] += t;
return;
}
int m = (st+dr)/2;
if(l1 <= m)
{
int main()
{
fin = fopen("hotel.in", "r");
fout = fopen("hotel.out", "w");
int i, a, x, y;
n=getInt(); m=getInt();
dfs(1, n, 1);
for(i=1;i<=m;++i)
{
a = getInt();
if(a == 3)
{
scrie(query());
putch('\n');
}
if(a == 2 || a==1)
{
x = getInt();
y = getInt();
l1 = x;
l2 = x + y - 1;
val = (a == 2 ? -1 : 1);
update(1, n, 1);
}
}
fwrite(buf2, 1, pos2, fout);
fclose(fin);
fclose(fout);
return 0;
}
inline char getChar()
{
if(pos == BUF_SIZE) pos = 0, fread(buf, 1, BUF_SIZE, fin);
return buf[pos++];
}
inline int getInt()
{
int nr = 0;
char c;
c=getChar();
while(!isdigit(c)) c=getChar();
while(isdigit(c))
{
nr = nr*10 + c-'0';
c = getChar();
}
return nr;
}
inline void putch(char c)
{
buf2[pos2++] = c;
if(pos2 == BUF_SIZE) fwrite(buf2, 1, BUF_SIZE, fout);
}
inline void scrie(int nr)
{
char s[10];
int k=0;
do
{
s[k++] = nr%10 + '0';
nr/=10;
}while(nr);
while(k)
{
--k;
putch(s[k]);
}
}