记录编号 |
122450 |
评测结果 |
AAAAAAAAAA |
题目名称 |
贪婪大陆 |
最终得分 |
100 |
用户昵称 |
HouJikan |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.145 s |
提交时间 |
2014-09-23 19:10:18 |
内存使用 |
1.07 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <iterator>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <functional>
#include <deque>
#define For(i,j,k) for(int i=(j);i<=(k);i++)
using namespace std;
typedef long long LL;
typedef unsigned int Uint;
const int INF=0x7fffffff;
const double eps=1e-6;
using namespace std;
//================struct declaration======================
//================var declaration=-========================
const int MAXN=100010;
int L[MAXN],R[MAXN];
int n,m,mine=0;
//================function declaration====================
int lowbit(int x){return x&-x;}
void add(int *Q,int x);
int query(int *Q,int x);
//================main code===============================
int main()
{
string ProgrammeName="greedisland";
string FloderName="COGS";
freopen((ProgrammeName+".in").c_str(),"r",stdin);
freopen((ProgrammeName+".out").c_str(),"w",stdout);
#ifdef DEBUG
clock_t Start_Time=clock();
system(("cp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\standard.cpp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\submit.txt").c_str());
#endif
scanf("%d%d",&n,&m);
For(i,1,m)
{
int cmd,s,e;
scanf("%d%d%d",&cmd,&s,&e);
if (cmd==1)//mine
{
add(L,s);
add(R,e);
mine++;
}
else
{
int res=0;
res+=query(R,s-1);
res+=query(L,n)-query(L,e);
printf("%d\n",mine-res);
}
}
#ifdef DEBUG
clock_t End_Time=clock();
printf("\n\nTime Used :%.6lf Ms\n",double(Start_Time-End_Time)/(-CLOCKS_PER_SEC));
#endif
return 0;
}
//================function code===========================
void add(int *Q,int x)
{
while (x<=n)
{
Q[x]++;
x+=lowbit(x);
}
return ;
}
int query(int *Q,int x)
{
int res=0;
while (x>0)
{
res+=Q[x];
x-=lowbit(x);
}
return res;
}