bit+容斥原理

我不会cdq分治只能用这个做法

考虑什么情况下不满足,至少有一个顺序不对就不行了,那么不满足的总有两对属性形成逆序对,那么我们用总方案数*2=n*(n-1)减去不符合的*2再/2就是答案

似乎进rank前200了

#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + ;
namespace IO
{
const int Maxlen = N * ;
char buf[Maxlen], *C = buf;
int Len;
inline void read_in()
{
Len = fread(C, , Maxlen, stdin);
buf[Len] = '\0';
}
inline void fread(int &x)
{
x = ;
int f = ;
while (*C < '' || '' < *C) { if(*C == '-') f = -; ++C; }
while ('' <= *C && *C <= '') x = (x << ) + (x << ) + *C - '', ++C;
x *= f;
}
inline void fread(long long &x)
{
x = ;
long long f = ;
while (*C < '' || '' < *C) { if(*C == '-') f = -; ++C; }
while ('' <= *C && *C <= '') x = (x << ) + (x << ) + *C - '', ++C;
x *= f;
}
inline void read(int &x)
{
x = ;
int f = ; char c = getchar();
while(c < '' || c > '') { if(c == '-') f = -; c = getchar(); }
while(c >= '' && c <= '') { x = (x << ) + (x << ) + c - ''; c = getchar(); }
x *= f;
}
inline void read(long long &x)
{
x = ;
long long f = ; char c = getchar();
while(c < '' || c > '') { if(c == '-') f = -; c = getchar(); }
while(c >= '' && c <= '') { x = (x << 1ll) + (x << 3ll) + c - ''; c = getchar(); }
x *= f;
}
} using namespace IO;
int n;
int t[N], a[N], b[N], c[N], pos[N];
void update(int x, int d)
{
for(; x <= n; x += x & -x) t[x] += d;
}
int query(int x)
{
int ret = ;
for(; x; x -= x & -x) ret += t[x];
return ret;
}
long long solve(int *a, int *b)
{
long long ret = ;
for(int i = ; i <= n; ++i)
{
pos[a[i]] = i;
t[i] = ;
}
for(int i = n; i; --i)
{
ret += query(pos[b[i]]);
update(pos[b[i]], );
}
return ret;
}
int main()
{
read_in();
fread(n);
for(int i = ; i <= n; ++i) fread(a[i]);
for(int i = ; i <= n; ++i) fread(b[i]);
for(int i = ; i <= n; ++i) fread(c[i]);
printf("%lld\n", ((long long)n * (long long)(n - ) - solve(a, b) - solve(b, c) - solve(c, a)) >> );
return ;
}

bzoj4430的更多相关文章

  1. bzoj4430 [Nwerc2015]Guessing Camels赌骆驼

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4430 [题解] 把每只骆驼在第一个人.第二个人.第三个人的位置找出来,然后做三维偏序即可. ...

随机推荐

  1. windows环境下生成ssh keys

    参考:https://www.cnblogs.com/achengmu/p/6095046.html 1.首先你要安装Git工具 2.运行Git Bash here 3.输入指令,进入.ssh文件夹 ...

  2. HDU 5667 :Sequence

    Sequence  Accepts: 59  Submissions: 650  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536 ...

  3. 微博达人硅谷之歌:Testin云測移动搜索性能測试非常是让人信服

    微博达人硅谷之歌:Testin云測移动搜索性能測试非常是让人信服 2014/10/08 · Testin · 开发人员訪谈 2013年11月1日,谷歌运行董事长施密特(Eric Emerson Sch ...

  4. MySQL提示Access denied for user &#39;&#39;@&#39;localhost&#39;”的解决

    记得那时由于没有网络,把rootpassword改错了写成了: update user set password="122" where user="root" ...

  5. RabbitMQ的工作模式

    简单模式: # #########################基于简单模式的 生产者 ######################### #!/usr/bin/env python import ...

  6. MySQL 创始人:写代码比打游戏爽,程序员应多泡开源社区

     王练 发布于2017年09月04日 收藏 43   开源中国全球专享福利,云栖大会购票大返现!>>>   根据StackOverflow的最新调查,MySQL仍然是全世界最流行的数 ...

  7. Linux中的du和df命令

    现在也将前阵子学习到du/df两个命令总结一下吧.前阵子测试工作中有遇到过由于磁盘空间满导致程序无法执行到情况,所以使用了df和du两个命令. du查看目录大小,df查看磁盘使用情况.我常使用的命令( ...

  8. Linux 系统监控.诊断工具之 IO wait

    1. 常用组合方式有如下几种: 用vmstat.sar.iostat检测是否是CPU瓶颈 用free.vmstat检测是否是内存瓶颈 用iostat.dmesg 检测是否是磁盘I/O瓶颈 用netst ...

  9. EasyPusher实现Android手机屏幕桌面直播,实时推送操作画面,用于手游直播等应用

    本文转自EasyDarwin开源团队成员John的博客:http://blog.csdn.net/jyt0551/article/details/52651194 由于Android 5.0提供了捕获 ...

  10. EasyDarwin开源流媒体服务器支持basic基本认证和digest摘要认证解析

    本文转自EasyDarwin开源团队成员ss的博客:http://blog.csdn.net/ss00_2012/article/details/52262621 RTSP认证作为RTSP标准协议的一 ...