题目:戳这里

学习博客:戳这里

作者:阿狸是狐狸啦

n个点,一个点集S是好的,当且仅当对于他的每个子集T,存在一个右边无限延长的矩形,使的这个矩形包含了T,但是和S-T没有交集。

求有多少个这种集合。

画图找规律可得

当我们求的集合中的点只有一个时,肯定满足要求 。

当有两个点且这两个点y坐标不相等也满足要求。

当有三个点组成一个小于号形状的集合S时,这个集合S的子集T一定与S-T无交集,当组成一个大于号时。我们取大于号左边的两个端点组成的T集合一定与右边的那个端点有交集。

当有四个点组成的S点集他一定存在一个子集T和S-T有交集。

所以我们计算小于等于三个点的情况就行了。

一的情况直接是n。

二的情况总的情况减去y坐标相等的点的情况就行了。

三的情况就是数一下有多少个小于号的情况,树状数组维护一下就行了。

附ac代码:

  1 #include <cstdio>
2 #include <cstring>
3 #include <algorithm>
4 #include <queue>
5 #include <stack>
6 #include <iostream>
7 using namespace std;
8 typedef long long ll;
9 const int maxn = 2 * 1e5 + 10;
10 const ll mod = 998244353;
11 struct nod
12 {
13 ll x;
14 ll y;
15 }coo[maxn];
16 ll cnt[maxn];
17 ll c[maxn<<2];
18 ll y[maxn];
19 ll n;
20 bool cmp(nod a, nod b)
21 {
22 return a.x > b.x;
23 }
24 ll pmul(ll a, ll b)
25 {
26 ll res = 0;
27 while(b)
28 {
29 if(b&1)
30 res = (res + a) % mod;
31 b >>= 1;
32 a = (a + a) % mod;
33 }
34 return res;
35 }
36 ll pmod(ll a, ll b)
37 {
38 ll res = 1;
39 while(b)
40 {
41 if(b&1)
42 res = pmul(res, a) % mod;
43 b >>= 1;
44 a = pmul(a, a) % mod;
45 }
46 return res;
47 }
48 ll gets(int x)
49 {
50 ll ans = 0;
51 while(x)
52 {
53 ans = (ans + c[x]) % mod;
54 x -= x & (-x);
55 }
56 return ans;
57 }
58 void updat(int x, ll ad)
59 {
60 while(x <= n)
61 {
62 c[x] = (c[x] + ad) % mod;
63 x += x & (-x);
64 }
65 }
66 int main() {
67
68 scanf("%d", &n);
69 for(ll i = 1; i <= n; ++i)
70 {
71 scanf("%d %d", &coo[i].x, &coo[i].y);
72 y[i] = coo[i].y;
73 }
74 sort(y + 1, y + 1 + n);
75 for(ll i = 1; i <= n; ++i)//这一步很有意思,把1e9的范围离散化到了1e5
76 {
77 ll u = lower_bound(y + 1, y + 1 + n, coo[i].y) - y;
78 coo[i].y = u;
79 ++cnt[u];
80 // printf("%d u\n", u);
81 }
82 sort(coo + 1, coo + 1 + n, cmp);
83 ll ans = n + n * (n - 1) / 2;
84 ans %= mod;
85 for(ll i = 1; i <= n; ++i)
86 {
87 ll u = cnt[i];
88 if(u)
89 ans = (ans - u * (u - 1) / 2) % mod;
90 }
91 ll up = 0, dw = 0;
92 ll now = 1;
93 for(ll i = 1; i <= n; ++i)
94 {
95 up = (gets(n) - gets(coo[i].y)) % mod;
96 dw = gets(coo[i].y - 1) % mod;
97 ans = (ans + up * dw % mod) % mod;
98 for(;coo[i].x != coo[i + 1].x && now <= i; ++now)
99 {
100 updat(coo[now].y, 1ll);
101 }
102 }
103 printf("%lld\n", ans % mod);
104 return 0;
105 }

牛客网多校第5场 I vcd 【树状数组+离散化处理】【非原创】的更多相关文章

  1. 牛客网多校训练第一场 I - Substring(后缀数组 + 重复处理)

    链接: https://www.nowcoder.com/acm/contest/139/I 题意: 给出一个n(1≤n≤5e4)个字符的字符串s(si ∈ {a,b,c}),求最多可以从n*(n+1 ...

  2. 牛客多校第3场 J 思维+树状数组+二分

    牛客多校第3场 J 思维+树状数组+二分 传送门:https://ac.nowcoder.com/acm/contest/883/J 题意: 给你q个询问,和一个队列容量f 询问有两种操作: 0.访问 ...

  3. 牛客网多校第3场C-shuffle card 平衡树或stl(rope)

    链接:https://www.nowcoder.com/acm/contest/141/C 来源:牛客网 题目描述 Eddy likes to play cards game since there ...

  4. 牛客网多校第3场Esort string (kmp)

    链接:https://www.nowcoder.com/acm/contest/141/E 来源:牛客网 题目描述 Eddy likes to play with string which is a ...

  5. 牛客网多校赛第九场A-circulant matrix【数论】

    链接:https://www.nowcoder.com/acm/contest/147/A 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524 ...

  6. 牛客网多校训练第二场D Kth Minimum Clique

    链接:https://ac.nowcoder.com/acm/contest/882/D来源:牛客网 Given a vertex-weighted graph with N vertices, fi ...

  7. 牛客网多校第5场 H subseq 【树状数组+离散化】

    题目:戳这里 学习博客:戳这里 题意:给n个数为a1~an,找到字典序第k小的序列,输出该序列所有数所在位置. 解题思路:先把所有序列预处理出来,方法是设一个数组为dp,dp[i]表示以i为开头的序列 ...

  8. 牛客练习赛33 D tokitsukaze and Inverse Number (树状数组求逆序对,结论)

    链接:https://ac.nowcoder.com/acm/contest/308/D 来源:牛客网 tokitsukaze and Inverse Number 时间限制:C/C++ 1秒,其他语 ...

  9. 牛客网多校第4场 J Hash Function 【思维+并查集建边】

    题目链接:戳这里 学习博客:戳这里 题意: 有n个空位,给一个数x,如果x%n位数空的,就把x放上去,如果不是空的,就看(x+1)%n是不是空的. 现在给一个已经放过数的状态,求放数字的顺序.(要求字 ...

随机推荐

  1. IE浏览器直接在页面中显示7z文件而不是下载问题解决

    IE浏览器中输入7z文件的完整下载URL后,不是保存文件,而是直接在页面中显示(当然是乱码) 这是因为浏览器对不同的资源文件处理的方式不同,例如图片文件,一般会直接打开,所以我们可以不用7z,使用zi ...

  2. Flask之静态文件处理

    静态文件的处理 推荐 from flask import Flask,render_template app = Flask(__name__,template_folder='templates', ...

  3. SpringBoot 2.0 中 HikariCP 数据库连接池原理解析

    作为后台服务开发,在日常工作中我们天天都在跟数据库打交道,一直在进行各种CRUD操作,都会使用到数据库连接池.按照发展历程,业界知名的数据库连接池有以下几种:c3p0.DBCP.Tomcat JDBC ...

  4. 1、进程管理常用命令和进程ID

    常用命令 1. ps (英文全拼:process status)命令用于显示当前进程的状态,类似于 windows 的任务管理器. 详细介绍参照:https://www.runoob.com/linu ...

  5. 让绝对定位的div居中

    最近看到一个问题就是让绝对定位的div居中,在尝试了top:50%:left:50%:后发现,居中是有问题的并不是想象中的样子 需要再加两句margin-top:-盒子高度的一般px  margin- ...

  6. 苹果 M1 芯片 OpenSSL 性能测试

    Apple M1(MacBook Air 2020) type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes md2 0.00 0.00 0.00 ...

  7. django 请求处理流程 链路追踪

    class BaseMiddleware: # https://github.com/django/django/blob/master/tests/utils_tests/test_decorato ...

  8. 配置《Orange's一个操作系统的实现》环境心得

    <Orange>这本书开篇第一章就做了一个实例,编写了一段引导扇区的代码,但是引导介质仍然采用了已被淘汰多年的软盘.在经历了两天的痛苦查找后终于找到了最方便的解决办法,在此做一下记录,希望 ...

  9. PAT甲级1056Mice and Rice

    目录 题目介绍 题解 解题思路 代码 参考链接 题目介绍 题目链接 https://pintia.cn/problem-sets/994805342720868352/problems/9948054 ...

  10. CF912A

    题意 你手里有 A 个黄水晶和 B 个蓝水晶,其中两个黄水晶可以造一个黄水晶球,三个蓝水晶可以造一个蓝水晶球,一黄一蓝两个水晶可以造一个绿水晶球. 现在你需要 x 个黄水晶球,y 个绿水晶球,z 个蓝 ...