记录编号 |
323268 |
评测结果 |
AAAAAAAAAA |
题目名称 |
罗伊德的防晒霜 |
最终得分 |
100 |
用户昵称 |
rewine |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
1.071 s |
提交时间 |
2016-10-16 11:17:06 |
内存使用 |
11.76 MiB |
显示代码纯文本
#pragma warning(disable: 4786)
#pragma G++ optimize ("O2")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <iostream>
#define Max(a,b) (a>b ? a:b)
#define Min(a,b) (a<b ? a:b)
#define Rep(_i,x,y) for(int _i = x; _i <= y;_i++)
using namespace std;
typedef unsigned int lg;
#define MAXX 1000009
//#define int long long
#define mod 19283746
inline bool read(int &x){
char c=getchar();
while(c!=EOF&&!isdigit(c)) c=getchar();
if(c==EOF) return 0; x=0;
while(isdigit(c)) {
x=x*10+c-'0';
c=getchar();
}
return 1;
}
int n,ans = 0;
struct data{
int x,y;
bool operator < (const data &lhs) const {
return this->y < lhs.y;
}
bool operator <= (const data &lhs) const {
if(y == lhs.y) return true;
return this->y < lhs.y;
}
}a[MAXX];
int t[MAXX];
bool cmp(const data &a,const data &b) {
return a.x < b.x;
}
void Msort(int l,int r) {
if(l == r) return;
int m = (l+r) >> 1;
Msort(l,m);Msort(m+1,r);
int i = l,j = m+1,top = l-1;
while(i <= m && j <= r) {
if(a[i] <= a[j]) t[++top] = a[i++].y;
else t[++top] = a[j++].y,ans = (ans+m-i+1)%mod;
}
while(i <= m) t[++top] = a[i++].y;
while(j <= r) t[++top] = a[j++].y;
for (int i = l; i <= r; i++)
a[i].y = t[i];
}
signed main(void) {
freopen("EOADtulad.in","r",stdin);
freopen("EOADtulad.out","w",stdout);
read(n);
Rep(i,1,n) read(a[i].x),read(a[i].y);
sort(a+1,a+n+1,cmp);
Msort(1,n);
printf("%d",ans);
return 0;
}