Tree-like array routines so, to determine an axis, but just learn to build a bad build.
Main.cpp//Richard////Created by Shaojinjie on 16/8/21. COPYRIGHT©2016 year Shaojinjie.
All rights reserved. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace
Std
typedef long Long LL;
const int MAXN=1000+10;
LL C[MAXN];
struct edge{int u,v;
BOOL operator < (const edge &e) Const {if (U!=E.U) return u<e.u;
Return v<e.v;
}}edge[500000];
int n,m,k;
void Add (int x) {while (x<=m) {c[x]++;
x+= (x& (-X));
} ll sum (int x) {ll s=0;
while (x) {s+=c[x];
x-= (x& (-X));
return s;
int main () {int t,kase=0;
scanf ("%d", &t);
while (t--) {memset (c,0,sizeof (c));
scanf ("%d%d%d", &n,&m,&k);
for (int i=0;i<k;i++) {scanf ("%d%d", &EDGE[I].U,&EDGE[I].V);
Sort (edge,edge+k);
LL ans=0; for (int i=0;i<k;i++) {ans+=sum (M)-sum (EDGE[I].V);
Add (EDGE[I].V);
printf ("Test Case%d:%lld\n", ++kase,ans);
return 0; }