| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
【求助】 为什么会RE?#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];
return tot;
}
void add(int 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]);
add(b[i]);
}
printf("%lld\n",sum);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator