QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#384140 | #3746. 千万别用树套树 | wanyurukong | WA | 161ms | 5204kb | C++98 | 1.3kb | 2024-04-09 20:54:04 | 2024-04-09 20:54:06 |
Judging History
answer
#include<bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define rep(x,a,b) for(int x=a;x<=b;x++)
// #define pre(x,a,b) for(int x=a;x>=b;x--)
#define endl "\n"
#define pb push_back
#define ll long long
#define int long long
#define pii pair<ll,ll>
#define psi pair<string, ll>
#define de cout<<1;
#define mem(a,x) memset(a,x,sizeof a)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int mod1=998244353;
const int mod2=1e9+7;
const int N = 1e5 + 60;
int number;
int n, m;
ll parl[N];
ll parr[N];
void addl(ll x)
{
for(ll i=x;i<=n;i+=lowbit(i))
{
parl[i]+=1;
}
}
void addr(ll x)
{
for(ll i=x;i<=n;i+=lowbit(i))
{
parr[i]+=1;
}
}
ll askl(ll x)
{
ll sum=0;
for(ll i=x;i;i-=lowbit(i))sum+=parl[i];
return sum;
}
ll askr(ll x)
{
ll sum=0;
for(ll i=x;i;i-=lowbit(i))
{
sum+=parr[i];
}
return sum;
}
void solve()
{
while(cin >> n >> m )
{
while(m--)
{
int op ,a, b;
cin >>op >> a >> b;
if(op==1)
{
addl(a);
addr(b+1);
}
else{
cout << askl(a)-askr(b-1)<<endl;
}
}
rep(i,0,n)parr[i]=0,parl[i]=0;
}
}
signed main()
{
IOS;
int _;
//cin >> _;
_ = 1;
while(_ -- )
{
number++;
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 161ms
memory: 5204kb
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...
output:
2 2 3 7 5 8 9 4 6 2 11 13 13 10 13 15 9 10 14 16 17 16 16 15 2 4 11 6 11 12 23 9 26 3 28 20 12 12 22 30 5 27 6 29 10 14 27 6 17 15 9 30 20 34 7 36 15 8 32 16 21 40 19 2 1 12 12 39 37 13 19 20 1 9 37 1 41 40 20 34 45 43 27 30 47 29 13 50 41 44 29 35 38 53 2 46 54 36 56 58 45 32 42 26 52 42 60 1 4 25 ...
result:
wrong answer 403rd numbers differ - expected: '97', found: '98'