QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#418343 | #3746. 千万别用树套树 | ZayinCTT# | RE | 0ms | 0kb | C++11 | 2.2kb | 2024-05-23 12:55:30 | 2024-05-23 12:55:30 |
Judging History
answer
// 那就是希望。
// 即便需要取模,也是光明。
#include <algorithm>
#include <random>
#include <stdio.h>
#include <vector>
typedef long long llt;
typedef unsigned uint;typedef unsigned long long ullt;
typedef bool bol;typedef char chr;typedef void voi;
typedef double dbl;
template<typename T>bol _max(T&a,T b){return(a<b)?a=b,true:false;}
template<typename T>bol _min(T&a,T b){return(b<a)?a=b,true:false;}
template<typename T>T lowbit(T n){return n&-n;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T lcm(T a,T b){return(a!=0||b!=0)?a/gcd(a,b)*b:(T)0;}
template<typename T>T exgcd(T a,T b,T&x,T&y){if(b!=0){T ans=exgcd(b,a%b,y,x);y-=a/b*x;return ans;}else return y=0,x=1,a;}
template<typename T>T power(T base,T index,T mod)
{
T ans=1%mod;
while(index)
{
if(index&1)ans=ans*base%mod;
base=base*base%mod,index>>=1;
}
return ans;
}
// Your shadow Gets in the way of my light
uint B[2][100005],Cnt[3][100005],n,q;
voi clear(uint*C)
{
for(uint i=0;i<=n;i++)C[i]=0;
}
voi add(uint*C,uint p)
{
p++;
while(p<=n)C[p]++,p+=lowbit(p);
}
uint find(uint*C,uint r)
{
uint ans=0;
while(r)ans+=C[r],r-=lowbit(r);
return ans;
}
uint find(uint*C,uint l,uint r)
{
return find(C,r)-find(C,l);
}
int main()
{
#ifdef MYEE
freopen("QAQ.in","r",stdin);
freopen("QAQ.out","w",stdout);
#endif
while(scanf("%u%u",&n,&q)==2&&n&&q)
{
while(q--)
{
uint o,l,r;scanf("%u%u%u",&o,&l,&r),l--,r--;
if(o==1)
{
add(B[0],l),add(B[1],r);
if(r-l<=2)Cnt[r-l][l]++;
}
else
{
uint ans=0;
ans+=find(B[0],l+1);
ans-=find(B[1],r);
for(uint i=l;i<r;i++)
for(uint j=i;j<r;j++)
ans+=Cnt[i][j];
printf("%u\n",ans);
}
}
clear(B[0]);
clear(B[1]);
clear(Cnt[0]);
clear(Cnt[1]);
clear(Cnt[2]);
}
return 0;
}
// 那就是希望。
// 即便需要取模,也是光明。
详细
Test #1:
score: 0
Runtime Error
input:
100000 100000 1 48500 63742 1 43673 89780 1 6471 44388 1 68054 71541 1 30056 91431 1 49687 70537 2 46899 46900 1 5165 57954 1 85892 88481 2 18060 18062 2 45289 45289 1 18927 67848 1 17389 96139 1 63451 92197 1 15473 87341 1 15162 15744 1 76728 99645 2 48730 48731 2 20886 20888 1 9756 67424 1 23175 4...