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

## 已解决……

Posted by 15632869526 at 2018-02-26 17:46:34 on Problem 3067
In Reply To:这道题怎么用逆序对解？ Posted by:15632869526 at 2018-02-26 17:39:19
```好吧，其实是我个ZZ在细节上写错了。

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 1e7+200;
struct stu{
long long s,e;
long long a[MAXN],ans,tmp[MAXN];
bool comp(const stu& A,const stu& B){
if(A.s!=B.s) return A.s<B.s;
else return A.e<B.e;
}
void Merge(int s,int m,int e){
int pb=0,p1=s,p2=m+1;
while(p1<=m&&p2<=e){
if(a[p1]<=a[p2]) tmp[pb++]=a[p1++];
else {
tmp[pb++]=a[p2++];
ans+=m-p1+1;
}
}
while(p1<=m) tmp[pb++]=a[p1++];
while(p2<=e) tmp[pb++]=a[p2++];
for(int i=0; i<e-s+1; i++) a[s+i]=tmp[i];
}
void Mergesort(int s,int e){
if(s<e){
int m=(e-s)/2+s;
Mergesort(s,m);
Mergesort(m+1,e);
Merge(s,m,e);
}
}
int main()
{
int t;
scanf("%d",&t);
for(int I=1; I<=t; I++){
ans=0;
int n,m,k;
scanf("%d %d %d",&n,&m,&k);
for(int i=1; i<=k; i++){
}
Mergesort(1,k);
printf("Test case %d: %lld\n",I,ans);
}
return 0;
}```

Followed by: