Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 【求助】 为什么会RE？

Posted by YoungNeal at 2018-02-15 14:01:27 on Problem 3067
```#include<cstdio>
#include<cstring>
#include<algorithm>
#define int long long
using namespace std;

int T,n,m,k,sum;
int f[1005],b[1005];

struct Node{
int x,y;
}node[100005];

int query(int x){
int tot=0;
for(;x;x-=x&-x)
tot+=f[x];
}

for(;x<=m;x+=x&-x)
f[x]++;
}

bool cmp(const int &a,const int &b){
if(node[a].x==node[b].x) return node[a].y<node[b].x;
return node[a].y>node[b].y;
}

signed main(){
scanf("%lld",&T);
for(int p=1;p<=T;p++){
printf("Test case %lld: ",p);
memset(f,0,sizeof f);
sum=0;
scanf("%lld%lld%lld",&n,&m,&k);
for(int i=1;i<=k;i++)
scanf("%lld%lld",&node[i].x,&node[i].y),b[i]=i;
sort(b+1,b+1+k,cmp);
for(int i=1;i<=k;i++){
sum+=query(b[i]);
}
printf("%lld\n",sum);
}
return 0;
}```

Followed by: