比赛 |
防止浮躁的小练习v0.4 |
评测结果 |
AAAAAAAAAA |
题目名称 |
罗伊德的防晒霜 |
最终得分 |
100 |
用户昵称 |
sxysxy |
运行时间 |
1.265 s |
代码语言 |
C++ |
内存使用 |
10.56 MiB |
提交时间 |
2016-10-13 15:24:50 |
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstdarg>
#include <list>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 1000003
#define MOD 19283746 //woc? ???.jpg
struct goodgame
{
int l, s;
bool operator<(const goodgame &o) const
{
return l < o.l;
}
}ggs[MAXN];
int ans = 0;
int tmp[MAXN];
void msort(int l, int m, int r)
{
int i = l;
int j = m+1;
int k = l;
while(i <= m && j <= r)
{
if(ggs[i].s > ggs[j].s)
{
tmp[k++] = ggs[j++].s;
ans = (ans+m-i+1)%MOD;
}else
{
tmp[k++] = ggs[i++].s;
}
}
while(i <= m)tmp[k++] = ggs[i++].s;
while(j <= r)tmp[k++] = ggs[j++].s;
for(int p = l; p <= r; p++)
ggs[p].s = tmp[p];
}
void gg(int l, int r)
{
if(l < r)
{
int m = (l+r)>>1;
gg(l, m);
gg(m+1, r);
msort(l, m, r);
}
}
int main()
{
//freopen("MatchNOIP2013.in", "r", stdin);
//freopen("MatchNOIP2013.out", "w", stdout);
freopen("EOADtulad.in", "r", stdin);
freopen("EOADtulad.out", "w", stdout);
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%d %d", &ggs[i].l, &ggs[i].s);
sort(ggs+1, ggs+1+n);
gg(1, n);
printf("%d\n", ans);
return 0;
}